本文整理汇总了C#中CGContext.AddRect方法的典型用法代码示例。如果您正苦于以下问题:C# CGContext.AddRect方法的具体用法?C# CGContext.AddRect怎么用?C# CGContext.AddRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGContext
的用法示例。
在下文中一共展示了CGContext.AddRect方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FillRect
public static void FillRect(CGContext context, RectangleF rect, CGColor color)
{
context.SaveState();
context.AddRect(rect);
context.Clip();
context.SetFillColor(color);
context.FillRect(rect);
context.RestoreState();
}
示例2: 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));
}
示例3: AddRoundedRectToPath
public static void AddRoundedRectToPath(CGContext context, RectangleF rect, float ovalWidth, float ovalHeight)
{
float fw, fh;
if (ovalWidth == 0 || ovalHeight == 0)
{
context.AddRect(rect);
return;
}
context.SaveState();
context.TranslateCTM(rect.GetMinX(), rect.GetMinY());
context.ScaleCTM(ovalWidth, ovalHeight);
fw = rect.Width / ovalWidth;
fh = rect.Height / ovalHeight;
context.MoveTo(fw, fh / 2);
context.AddArcToPoint(fw, fh, fw / 2, fh, 1);
context.AddArcToPoint(0, fh, 0, fh / 2, 1);
context.AddArcToPoint(0, 0, fw / 2, 0, 1);
context.AddArcToPoint(fw, 0, fw, fh / 2, 1);
context.ClosePath();
context.RestoreState();
}
示例4: FillGradient
public static void FillGradient(CGContext context, RectangleF rect, CGColor color1, CGColor color2)
{
CGGradient gradientBackground;
CGColorSpace colorSpace = CGColorSpace.CreateDeviceRGB();
float[] locationListBackground = new float[] { 1.0f, 0.0f };
List<float> colorListBackground = new List<float>();
colorListBackground.AddRange(color1.Components);
colorListBackground.AddRange(color2.Components);
gradientBackground = new CGGradient(colorSpace, colorListBackground.ToArray(), locationListBackground);
context.SaveState();
context.AddRect(rect);
context.Clip();
//context.ScaleCTM(1, -1);
context.DrawLinearGradient(gradientBackground, new PointF(rect.X, rect.Y), new PointF(rect.X + rect.Width, rect.Y + rect.Height), CGGradientDrawingOptions.DrawsBeforeStartLocation);
context.RestoreState();
}
示例5: DrawBackground
private void DrawBackground(CGContext context)
{
context.SetFillDialogBorderColor();
context.AddRect(
new RectangleF(Frame.X - Border,
Frame.Y - Border,
Frame.Width + 2 * Border,
Frame.Height + 2 * Border));
context.DrawPath(CGPathDrawingMode.Fill);
context.SetFillDialogBackgroungColor();
context.AddRect(Frame);
context.DrawPath(CGPathDrawingMode.Fill);
}