本文整理汇总了C#中CGPath.AddEllipseInRect方法的典型用法代码示例。如果您正苦于以下问题:C# CGPath.AddEllipseInRect方法的具体用法?C# CGPath.AddEllipseInRect怎么用?C# CGPath.AddEllipseInRect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGPath
的用法示例。
在下文中一共展示了CGPath.AddEllipseInRect方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public override void Draw(RectangleF rect)
{
var element = Element as CircleView;
if (element == null) {
throw new InvalidOperationException ("Element must be a Circle View type");
}
//get graphics context
using(CGContext context = UIGraphics.GetCurrentContext ()){
context.SetFillColor(element.FillColor.ToCGColor());
context.SetStrokeColor(element.StrokeColor.ToCGColor());
context.SetLineWidth(element.StrokeThickness);
if (element.StrokeDash > 1.0f) {
context.SetLineDash (
0,
new float[] { element.StrokeDash, element.StrokeDash });
}
//create geometry
var path = new CGPath ();
path.AddEllipseInRect (rect);
path.CloseSubpath();
//add geometry to graphics context and draw it
context.AddPath(path);
context.DrawPath(CGPathDrawingMode.FillStroke);
}
}
示例2: Draw
public override void Draw(CGRect rect)
{
//get graphics context
using (CGContext g = UIGraphics.GetCurrentContext())
{
//set up drawing attributes
UIColor.Black.SetFill();
//create geometry
_overlay = new CGPath();
_overlay.AddRect(new RectangleF(0f, 0f, _width, _height));
if(_isRound)
_overlay.AddEllipseInRect(new RectangleF((float)_rect.X, (float)_rect.Y, (float)_rect.Width, (float)_rect.Height));
else
_overlay.AddRect(new RectangleF((float)_rect.X, (float)_rect.Y, (float)_rect.Width, (float)_rect.Height));
g.SetStrokeColor(UIColor.Clear.CGColor);
g.SetAlpha(0.6f);
//add geometry to graphics context and draw it
g.AddPath(_overlay);
g.DrawPath(CGPathDrawingMode.EOFillStroke);
}
}
示例3: 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);
using (var path = new CGPath())
{
path.AddEllipseInRect(convertedRectangle);
this.gctx.AddPath(path);
}
this.gctx.DrawPath(CGPathDrawingMode.Fill);
}
if (stroke.IsVisible() && thickness > 0)
{
this.SetStroke(stroke, thickness);
using (var path = new CGPath())
{
path.AddEllipseInRect(convertedRectangle);
this.gctx.AddPath(path);
}
this.gctx.DrawPath(CGPathDrawingMode.Stroke);
}
}
示例4: 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.AddEllipseInRect(new CGRect(-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);
}
示例5: drawLines
void drawLines ()
{
layer.RemoveAllAnimations ();
var dot = new CGRect (0, 0, lineWidth, lineWidth);
nfloat x, y;
CGPoint start = CGPoint.Empty;
CGPoint end = CGPoint.Empty;
// Draw curved graph line
using (UIColor color = UIColor.White.ColorWithAlpha (0.25f), dotColor = UIColor.White.ColorWithAlpha (0.70f)) {
//color.SetStroke ();
//dotColor.SetFill ();
//ctx.SetLineWidth (lineWidth);
using (CGPath path = new CGPath ()) {
var count = hourly ? HourlyTemps.Count : (Forecasts.Count * 2);
for (int i = 0; i < count; i++) {
// adjusted index
var ai = i;
double temp;
if (hourly) {
temp = HourlyTemps [ai];
} else {
// reset start when switching from highs to lows
if (i == Forecasts.Count) start = CGPoint.Empty;
var highs = i < Forecasts.Count;
ai = highs ? i : i - Forecasts.Count;
temp = highs ? HighTemps [ai] : LowTemps [ai];
}
var percent = ((nfloat)temp - scaleLow) / scaleRange;
x = padding + inset + (ai * scaleX);
y = graphRect.GetMaxY () - (graphRect.Height * percent);
end = new CGPoint (x, y);
if (!hourly) {
dot.X = end.X - (lineWidth / 2);
dot.Y = end.Y - (lineWidth / 2);
path.AddEllipseInRect (dot);
//ctx.AddEllipseInRect (dot);
}
if (start == CGPoint.Empty) {
path.MoveToPoint (end);
} else {
path.MoveToPoint (start);
if (hourly) {
path.AddLineToPoint (end);
} else {
var diff = (end.X - start.X) / 2;
path.AddCurveToPoint (end.X - diff, start.Y, start.X + diff, end.Y, end.X, end.Y);
}
}
start = end;
}
// draw all dots to context
//if (!hourly) ctx.DrawPath (CGPathDrawingMode.Fill);
// add line path to context
layer.Path = path;
//ctx.AddPath (path);
//.........这里部分代码省略.........