本文整理汇总了C#中CGContext.ClosePath方法的典型用法代码示例。如果您正苦于以下问题:C# CGContext.ClosePath方法的具体用法?C# CGContext.ClosePath怎么用?C# CGContext.ClosePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGContext
的用法示例。
在下文中一共展示了CGContext.ClosePath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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 ();
}
示例2: DrawStarPattern
/// <summary>
/// This is a slightly more complicated draw pattern, but using it is just
/// as easy as the previous one. To use this one, simply change "DrawPolkaDotPattern"
/// in line 54 above to "DrawStarPattern"
/// </summary>
protected void DrawStarPattern (CGContext context)
{
// declare vars
float starDiameter = 16;
// 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));
}
// fill our star as dark gray
context.ClosePath ();
context.FillPath ();
}
示例3: icon_check_empty
static void icon_check_empty(CGContext c)
{
c.MoveTo(1120f,
1280f);
c.AddLineToPoint(288f,
1280f);
c.AddQuadCurveToPoint(222f,
1280f,
175f,
1233f);
c.AddQuadCurveToPoint(128f,
1186f,
128f,
1120f);
c.AddLineToPoint(128f,
288f);
c.AddQuadCurveToPoint(128f,
222f,
175f,
175f);
c.AddQuadCurveToPoint(222f,
128f,
288f,
128f);
c.AddLineToPoint(1120f,
128f);
c.AddQuadCurveToPoint(1186f,
128f,
1233f,
175f);
c.AddQuadCurveToPoint(1280f,
222f,
1280f,
288f);
c.AddLineToPoint(1280f,
1120f);
c.AddQuadCurveToPoint(1280f,
1186f,
1233f,
1233f);
c.AddQuadCurveToPoint(1186f,
1280f,
1120f,
1280f);
c.ClosePath();
c.MoveTo(1120f,
1280f);
c.MoveTo(1408f,
1120f);
c.AddLineToPoint(1408f,
288f);
c.AddQuadCurveToPoint(1408f,
169f,
1323.5f,
84.5f);
c.AddQuadCurveToPoint(1239f,
0f,
1120f,
0f);
c.AddLineToPoint(288f,
0f);
c.AddQuadCurveToPoint(169f,
0f,
84.5f,
84.5f);
c.AddQuadCurveToPoint(0f,
169f,
0f,
288f);
c.AddLineToPoint(0f,
1120f);
c.AddQuadCurveToPoint(0f,
1239f,
84.5f,
1323.5f);
c.AddQuadCurveToPoint(169f,
1408f,
288f,
1408f);
c.AddLineToPoint(1120f,
1408f);
c.AddQuadCurveToPoint(1239f,
1408f,
1323.5f,
1323.5f);
c.AddQuadCurveToPoint(1408f,
1239f,
1408f,
1120f);
c.ClosePath();
c.MoveTo(1408f,
1120f);
c.FillPath();
c.StrokePath();
}
示例4: DrawBorder
private void DrawBorder(CGContext context, RectangleF rect)
{
context.SaveState ();
context.BeginPath ();
float lineSize = 2f;
if (this.scaleFactor > 1) {
lineSize += this.scaleFactor * .25f;
}
context.SetLineWidth (lineSize);
context.SetStrokeColor (this.borderColor.CGColor);
MakePath (context, rect);
context.ClosePath ();
context.StrokePath ();
context.RestoreState ();
}
示例5: 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();
}
示例6: icon_comment
//.........这里部分代码省略.........
177f,
-256f);
c.AddQuadCurveToPoint(160f,
-258f,
146.5f,
-247f);
c.AddQuadCurveToPoint(133f,
-236f,
129f,
-218f);
c.AddLineToPoint(129f,
-217f);
c.AddQuadCurveToPoint(126f,
-213f,
128.5f,
-205f);
c.AddQuadCurveToPoint(131f,
-197f,
130.5f,
-195f);
c.AddQuadCurveToPoint(130f,
-193f,
135f,
-185.5f);
c.AddLineToPoint(141f,
-176.5f);
c.AddQuadCurveToPoint(141f,
-176.5f,
148f,
-168f);
c.AddQuadCurveToPoint(155f,
-159.5f,
156f,
-159f);
c.AddQuadCurveToPoint(163f,
-151f,
187f,
-124.5f);
c.AddQuadCurveToPoint(211f,
-98f,
221.5f,
-86.5f);
c.AddQuadCurveToPoint(232f,
-75f,
252.5f,
-47f);
c.AddQuadCurveToPoint(273f,
-19f,
285f,
4f);
c.AddQuadCurveToPoint(297f,
27f,
312f,
63f);
c.AddQuadCurveToPoint(327f,
99f,
338f,
139f);
c.AddQuadCurveToPoint(181f,
228f,
90.5f,
359f);
c.AddQuadCurveToPoint(0f,
490f,
0f,
640f);
c.AddQuadCurveToPoint(0f,
770f,
71f,
888.5f);
c.AddQuadCurveToPoint(142f,
1007f,
262f,
1093f);
c.AddQuadCurveToPoint(382f,
1179f,
548f,
1229.5f);
c.AddQuadCurveToPoint(714f,
1280f,
896f,
1280f);
c.AddQuadCurveToPoint(1140f,
1280f,
1346f,
1194.5f);
c.AddQuadCurveToPoint(1552f,
1109f,
1672f,
961.5f);
c.AddQuadCurveToPoint(1792f,
814f,
1792f,
640f);
c.ClosePath();
c.MoveTo(1792f,
640f);
c.FillPath();
c.StrokePath();
}
示例7: DrawInContext
public override void DrawInContext (CGContext context)
{
// Drawing with a white stroke color
context.SetStrokeColor (1, 1, 1, 1);
// And draw with a blue fill color
context.SetFillColor (0, 0, 1, 1);
// Draw them with a 2 stroke width so they are a bit more visible.
context.SetLineWidth (2);
// Add an ellipse circumscribed in the given rect to the current path, then stroke it
context.AddEllipseInRect (new CGRect (30, 30, 60, 60));
context.StrokePath ();
// Stroke ellipse convenience that is equivalent to AddEllipseInRect(); StrokePath();
context.StrokeEllipseInRect (new CGRect (30, 120, 60, 60));
// Fill rect convenience equivalent to AddEllipseInRect(); FillPath();
context.FillEllipseInRect (new CGRect (30, 210, 60, 60));
// Stroke 2 seperate arcs
context.AddArc (150, 60, 30, 0, (float)Math.PI / 2, false);
context.StrokePath ();
context.AddArc (150, 60, 30, (float)(3 * Math.PI / 2), (float)Math.PI, true);
context.StrokePath ();
// Stroke 2 arcs together going opposite directions.
context.AddArc (150, 150, 30, 0, (float)Math.PI / 2, false);
context.AddArc (150, 150, 30, (float)(3 * Math.PI / 2), (float)Math.PI, true);
context.StrokePath ();
// Stroke 2 arcs together going the same direction..
context.AddArc (150, 240, 30, 0, (float)(Math.PI / 2), false);
context.AddArc (150, 240, 30, (float)Math.PI, (float)(3 * Math.PI / 2), false);
context.StrokePath ();
// Stroke an arc using AddArcToPoint
CGPoint[] p = {
new CGPoint (210, 30),
new CGPoint (210, 60),
new CGPoint (240, 60),
};
context.MoveTo (p [0].X, p [0].Y);
context.AddArcToPoint (p [1].X, p [1].Y, p [2].X, p [2].Y, 30);
context.StrokePath ();
// Show the two segments that are used to determine the tangent lines to draw the arc.
context.SetStrokeColor (1, 0, 0, 1);
context.AddLines (p);
context.StrokePath ();
// As a bonus, we'll combine arcs to create a round rectangle!
// Drawing with a white stroke color
context.SetStrokeColor (1, 1, 1, 1);
// If you were making this as a routine, you would probably accept a rectangle
// that defines its bounds, and a radius reflecting the "rounded-ness" of the rectangle.
var rrect = new CGRect (210, 90, 60, 60);
var radius = 10;
// NOTE: At this point you may want to verify that your radius is no more than half
// the width and height of your rectangle, as this technique degenerates for those cases.
// In order to draw a rounded rectangle, we will take advantage of the fact that
// context.AddArcToPoint will draw straight lines past the start and end of the arc
// in order to create the path from the current position and the destination position.
// In order to create the 4 arcs correctly, we need to know the min, mid and max positions
// on the x and y lengths of the given rectangle.
nfloat minx = rrect.X, midx = rrect.X + rrect.Width / 2, maxx = rrect.X + rrect.Width;
nfloat miny = rrect.Y, midy = rrect.Y + rrect.Height / 2, maxy = rrect.Y + rrect.Height;
// Next, we will go around the rectangle in the order given by the figure below.
// minx midx maxx
// miny 2 3 4
// midy 1 9 5
// maxy 8 7 6
// Which gives us a coincident start and end point, which is incidental to this technique, but still doesn't
// form a closed path, so we still need to close the path to connect the ends correctly.
// Thus we start by moving to point 1, then adding arcs through each pair of points that follows.
// You could use a similar tecgnique to create any shape with rounded corners.
// Start at 1
context.MoveTo (minx, midy);
// Add an arc through 2 to 3
context.AddArcToPoint (minx, miny, midx, miny, radius);
// Add an arc through 4 to 5
context.AddArcToPoint (maxx, miny, maxx, midy, radius);
// Add an arc through 6 to 7
context.AddArcToPoint (maxx, maxy, midx, maxy, radius);
// Add an arc through 8 to 9
context.AddArcToPoint (minx, maxy, minx, midy, radius);
// Close the path
context.ClosePath ();
// Fill & stroke the path
context.DrawPath (CGPathDrawingMode.FillStroke);
}
示例8: icon_circle_arrow_down
static void icon_circle_arrow_down(CGContext c)
{
c.MoveTo(1284f,
639f);
c.AddQuadCurveToPoint(1284f,
666f,
1266f,
684f);
c.AddLineToPoint(1175f,
775f);
c.AddQuadCurveToPoint(1157f,
793f,
1130f,
793f);
c.AddQuadCurveToPoint(1103f,
793f,
1085f,
775f);
c.AddLineToPoint(896f,
586f);
c.AddLineToPoint(896f,
1088f);
c.AddQuadCurveToPoint(896f,
1114f,
877f,
1133f);
c.AddQuadCurveToPoint(858f,
1152f,
832f,
1152f);
c.AddLineToPoint(704f,
1152f);
c.AddQuadCurveToPoint(678f,
1152f,
659f,
1133f);
c.AddQuadCurveToPoint(640f,
1114f,
640f,
1088f);
c.AddLineToPoint(640f,
586f);
c.AddLineToPoint(451f,
775f);
c.AddQuadCurveToPoint(432f,
794f,
406f,
794f);
c.AddQuadCurveToPoint(380f,
794f,
361f,
775f);
c.AddLineToPoint(270f,
684f);
c.AddQuadCurveToPoint(252f,
666f,
252f,
639f);
c.AddQuadCurveToPoint(252f,
612f,
270f,
594f);
c.AddLineToPoint(632f,
232f);
c.AddLineToPoint(723f,
141f);
c.AddQuadCurveToPoint(741f,
123f,
768f,
123f);
c.AddQuadCurveToPoint(795f,
123f,
813f,
141f);
c.AddLineToPoint(904f,
232f);
c.AddLineToPoint(1266f,
594f);
c.AddQuadCurveToPoint(1284f,
612f,
1284f,
639f);
c.ClosePath();
c.MoveTo(1284f,
639f);
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,
//.........这里部分代码省略.........
示例9: icon_circle_arrow_left
static void icon_circle_arrow_left(CGContext c)
{
c.MoveTo(1280f,
576f);
c.AddLineToPoint(1280f,
704f);
c.AddQuadCurveToPoint(1280f,
730f,
1261f,
749f);
c.AddQuadCurveToPoint(1242f,
768f,
1216f,
768f);
c.AddLineToPoint(714f,
768f);
c.AddLineToPoint(903f,
957f);
c.AddQuadCurveToPoint(922f,
976f,
922f,
1002f);
c.AddQuadCurveToPoint(922f,
1028f,
903f,
1047f);
c.AddLineToPoint(812f,
1138f);
c.AddQuadCurveToPoint(794f,
1156f,
767f,
1156f);
c.AddQuadCurveToPoint(740f,
1156f,
722f,
1138f);
c.AddLineToPoint(360f,
776f);
c.AddLineToPoint(269f,
685f);
c.AddQuadCurveToPoint(251f,
667f,
251f,
640f);
c.AddQuadCurveToPoint(251f,
613f,
269f,
595f);
c.AddLineToPoint(360f,
504f);
c.AddLineToPoint(722f,
142f);
c.AddQuadCurveToPoint(740f,
124f,
767f,
124f);
c.AddQuadCurveToPoint(794f,
124f,
812f,
142f);
c.AddLineToPoint(903f,
233f);
c.AddQuadCurveToPoint(921f,
251f,
921f,
278f);
c.AddQuadCurveToPoint(921f,
305f,
903f,
323f);
c.AddLineToPoint(714f,
512f);
c.AddLineToPoint(1216f,
512f);
c.AddQuadCurveToPoint(1242f,
512f,
1261f,
531f);
c.AddQuadCurveToPoint(1280f,
550f,
1280f,
576f);
c.ClosePath();
c.MoveTo(1280f,
576f);
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,
//.........这里部分代码省略.........
示例10: icon_chevron_up
static void icon_chevron_up(CGContext c)
{
c.MoveTo(1611f,
320f);
c.AddQuadCurveToPoint(1611f,
267f,
1574f,
230f);
c.AddLineToPoint(1499f,
155f);
c.AddQuadCurveToPoint(1461f,
117f,
1408f,
117f);
c.AddQuadCurveToPoint(1354f,
117f,
1318f,
155f);
c.AddLineToPoint(832f,
640f);
c.AddLineToPoint(346f,
155f);
c.AddQuadCurveToPoint(310f,
117f,
256f,
117f);
c.AddQuadCurveToPoint(202f,
117f,
166f,
155f);
c.AddLineToPoint(91f,
230f);
c.AddQuadCurveToPoint(53f,
266f,
53f,
320f);
c.AddQuadCurveToPoint(53f,
373f,
91f,
411f);
c.AddLineToPoint(742f,
1062f);
c.AddQuadCurveToPoint(779f,
1099f,
832f,
1099f);
c.AddQuadCurveToPoint(884f,
1099f,
923f,
1062f);
c.AddLineToPoint(1573f,
411f);
c.AddQuadCurveToPoint(1611f,
373f,
1611f,
320f);
c.ClosePath();
c.MoveTo(1611f,
320f);
c.FillPath();
c.StrokePath();
}
示例11: icon_circle
static void icon_circle(CGContext c)
{
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();
}
示例12: icon_chevron_right
static void icon_chevron_right(CGContext c)
{
c.MoveTo(1099f,
704f);
c.AddQuadCurveToPoint(1099f,
652f,
1062f,
613f);
c.AddLineToPoint(410f,
-38f);
c.AddQuadCurveToPoint(373f,
-75f,
320f,
-75f);
c.AddQuadCurveToPoint(267f,
-75f,
230f,
-38f);
c.AddLineToPoint(154f,
37f);
c.AddQuadCurveToPoint(117f,
76f,
117f,
128f);
c.AddQuadCurveToPoint(117f,
181f,
154f,
218f);
c.AddLineToPoint(640f,
704f);
c.AddLineToPoint(154f,
1189f);
c.AddQuadCurveToPoint(117f,
1228f,
117f,
1280f);
c.AddQuadCurveToPoint(117f,
1333f,
154f,
1370f);
c.AddLineToPoint(230f,
1445f);
c.AddQuadCurveToPoint(266f,
1483f,
320f,
1483f);
c.AddQuadCurveToPoint(374f,
1483f,
410f,
1445f);
c.AddLineToPoint(1062f,
794f);
c.AddQuadCurveToPoint(1099f,
757f,
1099f,
704f);
c.ClosePath();
c.MoveTo(1099f,
704f);
c.FillPath();
c.StrokePath();
}
示例13: icon_chevron_left
static void icon_chevron_left(CGContext c)
{
c.MoveTo(742f,
-37f);
c.AddLineToPoint(90f,
614f);
c.AddQuadCurveToPoint(53f,
651f,
53f,
704.5f);
c.AddQuadCurveToPoint(53f,
758f,
90f,
795f);
c.AddLineToPoint(742f,
1446f);
c.AddQuadCurveToPoint(779f,
1483f,
832.5f,
1483f);
c.AddQuadCurveToPoint(886f,
1483f,
923f,
1446f);
c.AddLineToPoint(998f,
1371f);
c.AddQuadCurveToPoint(1035f,
1334f,
1035f,
1280.5f);
c.AddQuadCurveToPoint(1035f,
1227f,
998f,
1190f);
c.AddLineToPoint(512f,
704f);
c.AddLineToPoint(998f,
219f);
c.AddQuadCurveToPoint(1035f,
181f,
1035f,
128f);
c.AddQuadCurveToPoint(1035f,
75f,
998f,
38f);
c.AddLineToPoint(923f,
-37f);
c.AddQuadCurveToPoint(886f,
-74f,
832.5f,
-74f);
c.AddQuadCurveToPoint(779f,
-74f,
742f,
-37f);
c.ClosePath();
c.MoveTo(742f,
-37f);
c.FillPath();
c.StrokePath();
}
示例14: icon_chevron_down
static void icon_chevron_down(CGContext c)
{
c.MoveTo(1611f,
832f);
c.AddQuadCurveToPoint(1611f,
779f,
1574f,
742f);
c.AddLineToPoint(923f,
91f);
c.AddQuadCurveToPoint(885f,
53f,
832f,
53f);
c.AddQuadCurveToPoint(778f,
53f,
742f,
91f);
c.AddLineToPoint(91f,
742f);
c.AddQuadCurveToPoint(53f,
778f,
53f,
832f);
c.AddQuadCurveToPoint(53f,
885f,
91f,
923f);
c.AddLineToPoint(165f,
998f);
c.AddQuadCurveToPoint(204f,
1035f,
256f,
1035f);
c.AddQuadCurveToPoint(309f,
1035f,
346f,
998f);
c.AddLineToPoint(832f,
512f);
c.AddLineToPoint(1318f,
998f);
c.AddQuadCurveToPoint(1355f,
1035f,
1408f,
1035f);
c.AddQuadCurveToPoint(1460f,
1035f,
1499f,
998f);
c.AddLineToPoint(1574f,
923f);
c.AddQuadCurveToPoint(1611f,
884f,
1611f,
832f);
c.ClosePath();
c.MoveTo(1611f,
832f);
c.FillPath();
c.StrokePath();
}
示例15: icon_cogs
static void icon_cogs(CGContext c)
{
c.MoveTo(896f,
640f);
c.AddQuadCurveToPoint(896f,
746f,
821f,
821f);
c.AddQuadCurveToPoint(746f,
896f,
640f,
896f);
c.AddQuadCurveToPoint(534f,
896f,
459f,
821f);
c.AddQuadCurveToPoint(384f,
746f,
384f,
640f);
c.AddQuadCurveToPoint(384f,
534f,
459f,
459f);
c.AddQuadCurveToPoint(534f,
384f,
640f,
384f);
c.AddQuadCurveToPoint(746f,
384f,
821f,
459f);
c.AddQuadCurveToPoint(896f,
534f,
896f,
640f);
c.ClosePath();
c.MoveTo(896f,
640f);
c.MoveTo(1664f,
128f);
c.AddQuadCurveToPoint(1664f,
180f,
1626f,
218f);
c.AddQuadCurveToPoint(1588f,
256f,
1536f,
256f);
c.AddQuadCurveToPoint(1484f,
256f,
1446f,
218f);
c.AddQuadCurveToPoint(1408f,
180f,
1408f,
128f);
c.AddQuadCurveToPoint(1408f,
75f,
1445.5f,
37.5f);
c.AddQuadCurveToPoint(1483f,
0f,
1536f,
0f);
c.AddQuadCurveToPoint(1589f,
0f,
1626.5f,
37.5f);
c.AddQuadCurveToPoint(1664f,
75f,
1664f,
128f);
c.ClosePath();
c.MoveTo(1664f,
128f);
c.MoveTo(1664f,
1152f);
c.AddQuadCurveToPoint(1664f,
1204f,
1626f,
1242f);
c.AddQuadCurveToPoint(1588f,
1280f,
1536f,
1280f);
c.AddQuadCurveToPoint(1484f,
1280f,
1446f,
1242f);
c.AddQuadCurveToPoint(1408f,
1204f,
1408f,
1152f);
c.AddQuadCurveToPoint(1408f,
1099f,
1445.5f,
1061.5f);
c.AddQuadCurveToPoint(1483f,
1024f,
//.........这里部分代码省略.........