本文整理汇总了C#中CGPath.AddElipseInRect方法的典型用法代码示例。如果您正苦于以下问题:C# CGPath.AddElipseInRect方法的具体用法?C# CGPath.AddElipseInRect怎么用?C# CGPath.AddElipseInRect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGPath
的用法示例。
在下文中一共展示了CGPath.AddElipseInRect方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public override void Draw(System.Drawing.RectangleF rect)
{
//Get the current context
CGContext ctxt = UIGraphics.GetCurrentContext();
ctxt.ClearRect(rect);
//Set up the stroke and fill characteristics
ctxt.SetLineWidth(3.0f);
float[] gray = { 0.5f, 0.5f, 0.5f, 1.0f};
ctxt.SetStrokeColor(gray);
float[] red = { 0.75f, 0.25f, 0.25f, 1.0f};
ctxt.SetFillColor(red);
//Draw a line between the two location points
ctxt.MoveTo(Loc1.X, Loc1.Y);
ctxt.AddLineToPoint(Loc2.X, Loc2.Y);
ctxt.StrokePath();
var p1Box = new RectangleF(Loc1.X, Loc1.Y, 0.0f, 0.0f);
var p2Box = new RectangleF(Loc2.X, Loc2.Y, 0.0f, 0.0f);
var offset = -8.0f;
foreach(var r in new RectangleF[] {p1Box, p2Box})
{
using(var path = new CGPath())
{
var cpath = new CGPath();
r.Inflate (new SizeF (offset, offset));
cpath.AddElipseInRect(r);
ctxt.AddPath(cpath);
ctxt.FillPath();
}
}
}
示例2: DrawEllipse
/// <summary>
/// Draws an ellipse.
/// </summary>
/// <param name="rect">The rectangle.</param>
/// <param name="fill">The fill color.</param>
/// <param name="stroke">The stroke color.</param>
/// <param name="thickness">The thickness.</param>
public override void DrawEllipse(OxyRect rect, OxyColor fill, OxyColor stroke, double thickness)
{
this.SetAlias(false);
var convertedRectangle = rect.Convert();
if (fill.IsVisible())
{
this.SetFill(fill);
var path = new CGPath();
path.AddElipseInRect(convertedRectangle);
this.gctx.AddPath(path);
this.gctx.DrawPath(CGPathDrawingMode.Fill);
}
if (stroke.IsVisible() && thickness > 0)
{
this.SetStroke(stroke, thickness);
var path = new CGPath();
path.AddElipseInRect(convertedRectangle);
this.gctx.AddPath(path);
this.gctx.DrawPath(CGPathDrawingMode.Stroke);
}
}
示例3: CreateShape
public override void CreateShape(CGPath path, CGContext gctx)
{
path.AddElipseInRect (new RectangleF (_origin.X, _origin.Y, 100, 100));
gctx.AddPath (path);
gctx.DrawPath (CGPathDrawingMode.FillStroke);
}
示例4: Draw
public override void Draw(RectangleF rect)
{
var bounds = new RectangleF(0.0f, 0.0f, SIDELENGTH, SIDELENGTH);
var context = UIGraphics.GetCurrentContext();
var path = new CGPath();
//sp! Elipse [sic]
path.AddElipseInRect(this.Bounds);
context.AddPath(path);
context.Clip();
context.DrawPath(CGPathDrawingMode.Fill);
this.Image.Draw(bounds);
}
示例5: ClockView
public ClockView ()
{
// Set background to pink.
this.BackgroundColor = UIColor.FromRGB (1.0f, 0.8f, 0.8f);
// All paths are based on 100-unit clock radius
// centered at (0, 0)
// Define circle for tick marks.
tickMarks = new CGPath ();
tickMarks.AddElipseInRect(new RectangleF(-90, -90, 180, 180));
// Hour, minute, second hands defined to point straight up.
// Define hour hand.
hourHand = new CGPath ();
hourHand.MoveToPoint (0, -60);
hourHand.AddCurveToPoint (0, -30, 20, -30, 5, - 20);
hourHand.AddLineToPoint (5, 0);
hourHand.AddCurveToPoint (5, 7.5f, -5, 7.5f, -5, 0);
hourHand.AddLineToPoint (-5, -20);
hourHand.AddCurveToPoint (-20, -30, 0, -30, 0, -60);
hourHand.CloseSubpath ();
// Define minute hand.
minuteHand = new CGPath ();
minuteHand.MoveToPoint (0, -80);
minuteHand.AddCurveToPoint (0, -75, 0, -70, 2.5f, -60);
minuteHand.AddLineToPoint (2.5f, 0);
minuteHand.AddCurveToPoint (2.5f, 5, -2.5f, 5, -2.5f, 0);
minuteHand.AddLineToPoint (-2.5f, -60);
minuteHand.AddCurveToPoint (0, -70, 0, -75, 0, -80);
minuteHand.CloseSubpath ();
// Define second hand.
secondHand = new CGPath ();
secondHand.MoveToPoint (0, 10);
secondHand.AddLineToPoint(0, -80);
}
示例6: DrawEllipse
public override void DrawEllipse (OxyRect rect, OxyColor fill, OxyColor stroke, double thickness)
{
if (fill != null)
{
ToColor(fill).SetFill();
var path = new CGPath ();
path.AddElipseInRect(ToRectangle(rect));
gctx.AddPath (path);
gctx.DrawPath (CGPathDrawingMode.Fill);
}
if (stroke == null || thickness <= 0)
{
return;
}
SetAttributes (null, stroke, thickness);
var path2 = new CGPath ();
path2.AddElipseInRect(ToRectangle(rect));
gctx.AddPath (path2);
gctx.DrawPath (CGPathDrawingMode.Stroke);
}
示例7: drawCenter
private UIImage drawCenter ()
{
UIGraphics.BeginImageContext (new SizeF(64, 64));
using (CGContext cont = UIGraphics.GetCurrentContext()) {
using (CGPath path = new CGPath()) {
cont.SetLineWidth (1f);
cont.SetRGBStrokeColor (1f, 0, 0, 1);
cont.SetRGBFillColor (0.5f, 0, 0, 1);
path.AddElipseInRect(new RectangleF(24,24,16,16));
path.CloseSubpath ();
cont.AddPath (path);
cont.DrawPath (CGPathDrawingMode.FillStroke);
}
using (CGPath path = new CGPath()) {
cont.SetRGBStrokeColor (1f, 0, 0, 1);
cont.SetLineWidth(3f);
// cont.SetRGBFillColor (.5f, 0, 0, 1);
path.AddElipseInRect(new RectangleF(16,16,32,32));
path.CloseSubpath ();
cont.AddPath (path);
cont.DrawPath (CGPathDrawingMode.Stroke);
}
return UIGraphics.GetImageFromCurrentImageContext ();
}
UIGraphics.EndImageContext ();
}