本文整理汇总了C#中CGContext.FillPath方法的典型用法代码示例。如果您正苦于以下问题:C# CGContext.FillPath方法的具体用法?C# CGContext.FillPath怎么用?C# CGContext.FillPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGContext
的用法示例。
在下文中一共展示了CGContext.FillPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawInContext
public override void DrawInContext (CGContext context)
{
base.DrawInContext (context);
context.AddEllipseInRect (Bounds);
context.SetFillColor (ClockColor);
context.FillPath ();
}
示例2: DrawInContext
public override void DrawInContext(CGContext ctx)
{
base.DrawInContext (ctx);
// clip
var cornerRadius = Bounds.Height * Slider.Curvaceousness / 2.0f;
UIBezierPath switchOutline = UIBezierPath.FromRoundedRect( (CGRect)Bounds, (nfloat)cornerRadius);
ctx.AddPath (switchOutline.CGPath);
ctx.Clip ();
// 1) fill the track
ctx.SetFillColor (Slider.TrackColor.CGColor);
ctx.AddPath(switchOutline.CGPath);
ctx.FillPath ();
// 2) fill the highlighed range
ctx.SetFillColor(Slider.TrackHighlightColor.CGColor);
var lower = Slider.positionForValue (Slider.LowValue);
var higher = Slider.positionForValue(Slider.HighValue);
ctx.FillRect((CGRect)new CGRect(lower, 0, higher - lower, Bounds.Height));
// 3) add a highlight over the track
CGRect highlight = new CGRect(cornerRadius/2, Bounds.Height/2,
Bounds.Width - cornerRadius, Bounds.Height/2);
UIBezierPath highlightPath = UIBezierPath.FromRoundedRect ((CGRect)highlight, (nfloat)highlight.Height * Slider.Curvaceousness / 2.0f);
ctx.AddPath(highlightPath.CGPath);
ctx.SetFillColor( UIColor.FromWhiteAlpha((nfloat)1.0f, (nfloat)0.4f).CGColor);
ctx.FillPath ();
// 4) inner shadow
ctx.SetShadow( new CGSize(0f, 2.0f), 3.0f, UIColor.Gray.CGColor);
ctx.AddPath (switchOutline.CGPath);
ctx.SetStrokeColor(UIColor.Gray.CGColor);
ctx.StrokePath ();
// 5) outline the track
ctx.AddPath( switchOutline.CGPath);
ctx.SetStrokeColor(UIColor.Black.CGColor);
ctx.SetLineWidth ((nfloat)0.5f);
ctx.StrokePath ();
}
示例3: DrawInContext
public override void DrawInContext(CGContext ctx)
{
base.DrawInContext (ctx);
// clip
var cornerRadius = Bounds.Height / 2.0f;
UIBezierPath switchOutline = UIBezierPath.FromRoundedRect( (CGRect)Bounds, (nfloat)cornerRadius);
ctx.AddPath (switchOutline.CGPath);
ctx.Clip ();
// 1) fill the track
ctx.SetFillColor (UIColor.Green.CGColor);
ctx.AddPath(switchOutline.CGPath);
ctx.FillPath ();
// 2) fill the highlighed range //Skipped for demo
// 3) add a highlight over the track
CGRect highlight = new CGRect(cornerRadius/2, Bounds.Height/2,
Bounds.Width - cornerRadius, Bounds.Height/2);
UIBezierPath highlightPath = UIBezierPath.FromRoundedRect ((CGRect)highlight, (nfloat)highlight.Height / 2.0f);
ctx.AddPath(highlightPath.CGPath);
ctx.SetFillColor( UIColor.FromWhiteAlpha((nfloat)1.0f, (nfloat)0.4f).CGColor);
ctx.FillPath ();
// 4) inner shadow
ctx.SetShadow( new CGSize(0f, 2.0f), 3.0f, UIColor.Gray.CGColor);
ctx.AddPath (switchOutline.CGPath);
ctx.SetStrokeColor(UIColor.Gray.CGColor);
ctx.StrokePath ();
// 5) outline the track
ctx.AddPath( switchOutline.CGPath);
ctx.SetStrokeColor(UIColor.Black.CGColor);
ctx.SetLineWidth ((nfloat)0.5f);
ctx.StrokePath ();
//
// ctx.SetFillColor (UIColor.Blue.CGColor);
// ctx.FillRect (Bounds);
}
示例4: DrawInContext
public override void DrawInContext (CGContext ctx)
{
base.DrawInContext (ctx);
var bounds = Bounds;
var c = new PointF (bounds.GetMidX (), bounds.GetMidY ());
ctx.BeginPath ();
ctx.MoveTo (c.X, c.Y);
ctx.AddLineToPoint (bounds.Right, c.Y);
ctx.AddArc (c.X, c.Y, bounds.Width/2, (float)0, (float)Angle, false);
ctx.AddLineToPoint (c.X, c.Y);
ctx.SetFillColor (otherColor);
ctx.FillPath ();
ctx.BeginPath ();
ctx.MoveTo (c.X, c.Y);
ctx.AddLineToPoint (bounds.Right, c.Y);
ctx.AddArc (c.X, c.Y, bounds.Width/2, (float)0, (float)(1e-7 + Angle), true);
ctx.AddLineToPoint (c.X, c.Y);
ctx.SetFillColor (color);
ctx.FillPath ();
}
示例5: DrawStar
/// <summary>
/// Draws a star at the bottom left of the context of the specified diameter
/// </summary>
protected void DrawStar (CGContext context, float starDiameter)
{
// declare vars
// 144º
float theta = 2 * (float)Math.PI * (2f / 5f);
float radius = starDiameter / 2;
// move up and over
context.TranslateCTM (starDiameter / 2, starDiameter / 2);
context.MoveTo (0, radius);
for (int i = 1; i < 5; i++) {
context.AddLineToPoint (radius * (float)Math.Sin (i * theta), radius * (float)Math.Cos (i * theta));
}
//context.SetRGBFillColor (1, 1, 1, 1);
context.ClosePath ();
context.FillPath ();
}
示例6: DrawInContext
public override void DrawInContext (CGContext context)
{
// Drawing with a white stroke color
context.SetRGBStrokeColor (1, 1, 1, 1);
// And drawing with a blue fill color
context.SetRGBFillColor (0, 0, 1, 1);
// Draw them with a 2 stroke width so they are a bit more visible.
context.SetLineWidth (2);
// Add Rect to the current path, then stroke it
context.AddRect (new RectangleF (30, 30, 60, 60));
context.StrokePath ();
// Stroke Rect convenience that is equivalent to above
context.StrokeRect (new RectangleF (30, 120, 60, 60));
// Stroke rect convenience equivalent to the above, plus a call to context.SetLineWidth ().
context.StrokeRectWithWidth (new RectangleF (30, 210, 60, 60), 10);
// Demonstate the stroke is on both sides of the path.
context.SaveState ();
context.SetRGBStrokeColor (1, 0, 0, 1);
context.StrokeRectWithWidth (new RectangleF (30, 210, 60, 60), 2);
context.RestoreState ();
var rects = new RectangleF []
{
new RectangleF (120, 30, 60, 60),
new RectangleF (120, 120, 60, 60),
new RectangleF (120, 210, 60, 60),
};
// Bulk call to add rects to the current path.
context.AddRects (rects);
context.StrokePath ();
// Create filled rectangles via two different paths.
// Add/Fill path
context.AddRect (new RectangleF (210, 30, 60, 60));
context.FillPath ();
// Fill convienience.
context.FillRect (new RectangleF (210, 120, 60, 60));
}
示例7: icon_circle_arrow_up
//.........这里部分代码省略.........
505f);
c.AddLineToPoint(640f,
694f);
c.AddLineToPoint(640f,
192f);
c.AddQuadCurveToPoint(640f,
166f,
659f,
147f);
c.AddQuadCurveToPoint(678f,
128f,
704f,
128f);
c.AddLineToPoint(832f,
128f);
c.AddQuadCurveToPoint(858f,
128f,
877f,
147f);
c.AddQuadCurveToPoint(896f,
166f,
896f,
192f);
c.AddLineToPoint(896f,
694f);
c.AddLineToPoint(1085f,
505f);
c.AddQuadCurveToPoint(1104f,
486f,
1130f,
486f);
c.AddQuadCurveToPoint(1156f,
486f,
1175f,
505f);
c.AddLineToPoint(1266f,
596f);
c.AddQuadCurveToPoint(1284f,
614f,
1284f,
641f);
c.ClosePath();
c.MoveTo(1284f,
641f);
c.MoveTo(1536f,
640f);
c.AddQuadCurveToPoint(1536f,
431f,
1433f,
254.5f);
c.AddQuadCurveToPoint(1330f,
78f,
1153.5f,
-25f);
c.AddQuadCurveToPoint(977f,
-128f,
768f,
-128f);
c.AddQuadCurveToPoint(559f,
-128f,
382.5f,
-25f);
c.AddQuadCurveToPoint(206f,
78f,
103f,
254.5f);
c.AddQuadCurveToPoint(0f,
431f,
0f,
640f);
c.AddQuadCurveToPoint(0f,
849f,
103f,
1025.5f);
c.AddQuadCurveToPoint(206f,
1202f,
382.5f,
1305f);
c.AddQuadCurveToPoint(559f,
1408f,
768f,
1408f);
c.AddQuadCurveToPoint(977f,
1408f,
1153.5f,
1305f);
c.AddQuadCurveToPoint(1330f,
1202f,
1433f,
1025.5f);
c.AddQuadCurveToPoint(1536f,
849f,
1536f,
640f);
c.ClosePath();
c.MoveTo(1536f,
640f);
c.FillPath();
c.StrokePath();
}
示例8: SSDrawRoundedRect
public void SSDrawRoundedRect(CGContext context, RectangleF rect, float cornerRadius)
{
var minx = rect.GetMinX();
var midx = rect.GetMidX();
var maxx = rect.GetMaxX();
var miny = rect.GetMinY();
var midy = rect.GetMidY();
var maxy = rect.GetMaxY();
context.MoveTo(minx, midy);
context.AddArcToPoint(minx, miny, midx, miny, cornerRadius);
context.AddArcToPoint(maxx, miny, maxx, midy, cornerRadius);
context.AddArcToPoint(maxx, maxy, midx, maxy, cornerRadius);
context.AddArcToPoint(minx, maxy, minx, midy, cornerRadius);
context.ClosePath();
context.FillPath();
}
示例9: Draw
public override void Draw(RectangleF bounds, CGContext context, UIView view)
{
var leftMargin = LeftRightPadding;
// Superview is the container, its superview the uitableviewcell
var uiTableViewCell = view.Superview.Superview as UITableViewCell;
bool highlighted = uiTableViewCell != null && uiTableViewCell.Highlighted & IsTappedAssigned;
var timeColor = highlighted ? UIColor.White : UIColor.Gray;
var textColor = highlighted ? UIColor.White : UIColor.FromRGB(41, 41, 41);
var nameColor = highlighted ? UIColor.White : UIColor.FromRGB(0, 64, 128);
if (Image != null)
{
var imageRect = new RectangleF(LeftRightPadding, TopBottomPadding, 32f, 32f);
UIColor.White.SetColor ();
context.SaveState ();
//context.TranslateCTM (imageRect.X, imageRect.Y);
context.SetLineWidth (1);
// On device, the shadow is painted in the opposite direction!
context.SetShadowWithColor (new SizeF (0, 0), 3, UIColor.DarkGray.CGColor);
context.AddPath (UIBezierPath.FromRect(imageRect).CGPath);
context.FillPath ();
context.RestoreState ();
Image.Draw(imageRect);
leftMargin += LeftRightPadding + imageRect.Width + 3f;
}
var contentWidth = bounds.Width - LeftRightPadding - leftMargin;
var daysAgo = Time.ToDaysAgo();
timeColor.SetColor();
var daysWidth = daysAgo.MonoStringLength(DateFont);
RectangleF timeRect;
timeRect = Image != null ? new RectangleF(leftMargin, TopBottomPadding + UserFont.LineHeight, daysWidth, DateFont.LineHeight) :
new RectangleF(bounds.Width - LeftRightPadding - daysWidth, TopBottomPadding + 1f, daysWidth, DateFont.LineHeight);
view.DrawString(daysAgo, timeRect, DateFont, UILineBreakMode.TailTruncation);
nameColor.SetColor();
view.DrawString(Name,
new RectangleF(leftMargin, TopBottomPadding, contentWidth, UserFont.LineHeight),
UserFont, UILineBreakMode.TailTruncation
);
if (!string.IsNullOrEmpty(String))
{
UIColor.Black.SetColor();
var top = TopBottomPadding + UserFont.LineHeight + 3f;
if (Image != null)
top += DateFont.LineHeight;
textColor.SetColor();
if (Image == null)
{
view.DrawString(String,
new RectangleF(LeftRightPadding, top, bounds.Width - LeftRightPadding * 2, bounds.Height - TopBottomPadding - top),
DescFont, UILineBreakMode.TailTruncation
);
}
else
{
view.DrawString(String,
new RectangleF(leftMargin, top, contentWidth, bounds.Height - TopBottomPadding - top),
DescFont, UILineBreakMode.TailTruncation
);
}
}
}
示例10: icon_cloud_upload
//.........这里部分代码省略.........
256f,
1014.5f,
265.5f);
c.AddQuadCurveToPoint(1024f,
275f,
1024f,
288f);
c.AddLineToPoint(1024f,
640f);
c.AddLineToPoint(1248f,
640f);
c.AddQuadCurveToPoint(1261f,
640f,
1270.5f,
649.5f);
c.AddQuadCurveToPoint(1280f,
659f,
1280f,
672f);
c.ClosePath();
c.MoveTo(1280f,
672f);
c.MoveTo(1920f,
384f);
c.AddQuadCurveToPoint(1920f,
225f,
1807.5f,
112.5f);
c.AddQuadCurveToPoint(1695f,
0f,
1536f,
0f);
c.AddLineToPoint(448f,
0f);
c.AddQuadCurveToPoint(263f,
0f,
131.5f,
131.5f);
c.AddQuadCurveToPoint(0f,
263f,
0f,
448f);
c.AddQuadCurveToPoint(0f,
578f,
70f,
688f);
c.AddQuadCurveToPoint(140f,
798f,
258f,
853f);
c.AddQuadCurveToPoint(256f,
883f,
256f,
896f);
c.AddQuadCurveToPoint(256f,
1108f,
406f,
1258f);
c.AddQuadCurveToPoint(556f,
1408f,
768f,
1408f);
c.AddQuadCurveToPoint(924f,
1408f,
1053.5f,
1321f);
c.AddQuadCurveToPoint(1183f,
1234f,
1242f,
1090f);
c.AddQuadCurveToPoint(1313f,
1152f,
1408f,
1152f);
c.AddQuadCurveToPoint(1514f,
1152f,
1589f,
1077f);
c.AddQuadCurveToPoint(1664f,
1002f,
1664f,
896f);
c.AddQuadCurveToPoint(1664f,
820f,
1623f,
758f);
c.AddQuadCurveToPoint(1753f,
727f,
1836.5f,
622.5f);
c.AddQuadCurveToPoint(1920f,
518f,
1920f,
384f);
c.ClosePath();
c.MoveTo(1920f,
384f);
c.FillPath();
c.StrokePath();
}
示例11: drawSlicesWithRadius
void drawSlicesWithRadius(float radius, PointF center, CGContext contextRef)
{
bool cgClockwise = !Clockwise;
uint startingSlice = StartingSlice - 1;
if (ProgressCounter == 0 && Theme.DrawIncompleteArcIfNoProgress)
{
DrawArcInContext(contextRef, center, radius, 0, M_PI * 2, Theme.IncompletedColor.CGColor, cgClockwise);
return;
}
if (!Theme.SliceDividerHidden && Theme.SliceDividerThickness > 0)
{
float sliceAngle = (2 * M_PI) / ProgressTotal;
for (int i =0; i < ProgressTotal; i++) {
float startValue = (sliceAngle * i) + sliceAngle * startingSlice;
float startAngle, endAngle;
if (Clockwise)
{
startAngle = -M_PI_2 + startValue;
endAngle = startAngle + sliceAngle;
}
else
{
startAngle = -M_PI_2 - startValue;
endAngle = startAngle - sliceAngle;
}
contextRef.BeginPath();
contextRef.MoveTo(center.X, center.Y);
contextRef.AddArc(center.X, center.Y, radius, startAngle, endAngle, cgClockwise);
CGColor color = Theme.IncompletedColor.CGColor;
if (i < ProgressCounter)
{
color = Theme.CompletedColor.CGColor;
}
contextRef.SetFillColor(color);
contextRef.FillPath();
}
}
else
{
double originAngle, endAngle;
double sliceAngle = (2 * M_PI) / ProgressTotal;
double startingAngle = sliceAngle * startingSlice;
double progressAngle = sliceAngle * ProgressCounter;
if (Clockwise) {
originAngle = - M_PI_2 + startingAngle;
endAngle = originAngle + progressAngle;
} else {
originAngle = - M_PI_2 - startingAngle;
endAngle = originAngle - progressAngle;
}
DrawArcInContext(contextRef, center, radius, (float)originAngle, (float)endAngle, Theme.CompletedColor.CGColor, cgClockwise);
if (ProgressCounter < ProgressTotal)
{
DrawArcInContext(contextRef, center, radius, (float)endAngle, (float)originAngle, Theme.IncompletedColor.CGColor, cgClockwise);
}
}
}
示例12: icon_circle_arrow_right
//.........这里部分代码省略.........
704f);
c.AddLineToPoint(256f,
576f);
c.AddQuadCurveToPoint(256f,
550f,
275f,
531f);
c.AddQuadCurveToPoint(294f,
512f,
320f,
512f);
c.AddLineToPoint(822f,
512f);
c.AddLineToPoint(633f,
323f);
c.AddQuadCurveToPoint(614f,
304f,
614f,
278f);
c.AddQuadCurveToPoint(614f,
252f,
633f,
233f);
c.AddLineToPoint(724f,
142f);
c.AddQuadCurveToPoint(742f,
124f,
769f,
124f);
c.AddQuadCurveToPoint(796f,
124f,
814f,
142f);
c.AddLineToPoint(1176f,
504f);
c.AddLineToPoint(1267f,
595f);
c.AddQuadCurveToPoint(1285f,
613f,
1285f,
640f);
c.ClosePath();
c.MoveTo(1285f,
640f);
c.MoveTo(1536f,
640f);
c.AddQuadCurveToPoint(1536f,
431f,
1433f,
254.5f);
c.AddQuadCurveToPoint(1330f,
78f,
1153.5f,
-25f);
c.AddQuadCurveToPoint(977f,
-128f,
768f,
-128f);
c.AddQuadCurveToPoint(559f,
-128f,
382.5f,
-25f);
c.AddQuadCurveToPoint(206f,
78f,
103f,
254.5f);
c.AddQuadCurveToPoint(0f,
431f,
0f,
640f);
c.AddQuadCurveToPoint(0f,
849f,
103f,
1025.5f);
c.AddQuadCurveToPoint(206f,
1202f,
382.5f,
1305f);
c.AddQuadCurveToPoint(559f,
1408f,
768f,
1408f);
c.AddQuadCurveToPoint(977f,
1408f,
1153.5f,
1305f);
c.AddQuadCurveToPoint(1330f,
1202f,
1433f,
1025.5f);
c.AddQuadCurveToPoint(1536f,
849f,
1536f,
640f);
c.ClosePath();
c.MoveTo(1536f,
640f);
c.FillPath();
c.StrokePath();
}
示例13: DrawRoundedRect
private void DrawRoundedRect(CGContext context, RectangleF rect)
{
context.SaveState ();
context.BeginPath ();
context.SetFillColor (badgeColor.CGColor);
MakePath (context, rect);
context.SetShadowWithColor (new SizeF (1.0f, 1.0f), 3, UIColor.Black.CGColor);
context.FillPath ();
context.RestoreState ();
}
示例14: icon_comments
//.........这里部分代码省略.........
c.AddQuadCurveToPoint(1602f,
-11f,
1620f,
-30f);
c.AddQuadCurveToPoint(1638f,
-49f,
1643f,
-55f);
c.AddQuadCurveToPoint(1644f,
-56f,
1647f,
-59.5f);
c.AddQuadCurveToPoint(1650f,
-63f,
1651.5f,
-64.5f);
c.AddQuadCurveToPoint(1653f,
-66f,
1655.5f,
-69.5f);
c.AddQuadCurveToPoint(1658f,
-73f,
1659f,
-75f);
c.AddLineToPoint(1661.5f,
-80f);
c.AddQuadCurveToPoint(1661.5f,
-80f,
1663.5f,
-86f);
c.AddQuadCurveToPoint(1665.5f,
-92f,
1664f,
-92.5f);
c.AddQuadCurveToPoint(1662.5f,
-93f,
1663f,
-99f);
c.AddQuadCurveToPoint(1660f,
-113f,
1650f,
-121f);
c.AddQuadCurveToPoint(1640f,
-129f,
1628f,
-128f);
c.AddQuadCurveToPoint(1578f,
-121f,
1542f,
-112f);
c.AddQuadCurveToPoint(1388f,
-72f,
1264f,
16f);
c.AddQuadCurveToPoint(1174f,
0f,
1088f,
0f);
c.AddQuadCurveToPoint(817f,
0f,
616f,
132f);
c.AddQuadCurveToPoint(674f,
128f,
704f,
128f);
c.AddQuadCurveToPoint(865f,
128f,
1013f,
173f);
c.AddQuadCurveToPoint(1161f,
218f,
1277f,
302f);
c.AddQuadCurveToPoint(1402f,
394f,
1469f,
514f);
c.AddQuadCurveToPoint(1536f,
634f,
1536f,
768f);
c.AddQuadCurveToPoint(1536f,
845f,
1513f,
920f);
c.AddQuadCurveToPoint(1642f,
849f,
1717f,
742f);
c.AddQuadCurveToPoint(1792f,
635f,
1792f,
512f);
c.ClosePath();
c.MoveTo(1792f,
512f);
c.FillPath();
c.StrokePath();
}
示例15: FillRoundedRect
public static void FillRoundedRect(CGContext ctx, CGRect rect, float radius)
{
var p = GraphicsUtil.MakeRoundedRectPath(rect, radius);
ctx.AddPath(p);
ctx.FillPath();
}