本文整理汇总了C#中CGPath.AddArc方法的典型用法代码示例。如果您正苦于以下问题:C# CGPath.AddArc方法的具体用法?C# CGPath.AddArc怎么用?C# CGPath.AddArc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGPath
的用法示例。
在下文中一共展示了CGPath.AddArc方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public override void Draw(CGRect rect)
{
//get graphics context
using (CGContext g = UIGraphics.GetCurrentContext())
{
g.SetLineWidth(_lineWidth);
//set up drawing attributes
UIColor.Clear.SetFill();
if (_isRound)
{
var circle = new CGPath();
var circleSize = rect.Size.Width / 2;
circle.AddArc(circleSize, circleSize, circleSize, 0, endangle, true);
Console.WriteLine("circleSize: {0}", circleSize);
g.AddPath(circle);
}
else
{
//create geometry
var rectangle = new CGPath();
rectangle.AddRect(new RectangleF(0f, 0f, (float)rect.Size.Width, (float)rect.Size.Height));
rectangle.CloseSubpath();
//add geometry to graphics context and draw it
g.AddPath(rectangle);
}
g.SetStrokeColor(_color.CGColor);
g.SetAlpha(_transparancy);
g.DrawPath(CGPathDrawingMode.Stroke);
}
}
示例2: CreatePieSegment
private UIImage CreatePieSegment(CGSize size, nfloat endAngle)
{
// Add the arc
var arc = new CGPath();
arc.MoveToPoint(size.Width / 2.0f, size.Height / 2.0f);
arc.AddLineToPoint(size.Width / 2.0f, 0);
arc.AddArc(size.Width / 2.0f, size.Height / 2.0f, size.Width / 2.0f, _startAngle, endAngle, false);
arc.AddLineToPoint(size.Width / 2.0f, size.Height / 2.0f);
// Stroke the arc
UIGraphics.BeginImageContextWithOptions(size, false, 0);
var context = UIGraphics.GetCurrentContext();
context.AddPath(arc);
context.SetFillColor(UIColor.FromRGBA(0f, 0f, 0f, 1f).CGColor);
context.FillPath();
// Get the mask image
var image = UIGraphics.GetImageFromCurrentImageContext();
UIGraphics.EndImageContext();
return image;
}
示例3: AddAnchorDotToSprite
void AddAnchorDotToSprite (SKSpriteNode sprite)
{
CGPath myPath = new CGPath ();
myPath.AddArc (0, 0, 10, 0, (float) Math.PI * 2, true);
myPath.CloseSubpath ();
SKShapeNode dot = new SKShapeNode () {
Path = myPath,
FillColor = UIColor.Green,
LineWidth = 0.0f
};
sprite.AddChild (dot);
}
示例4: Draw
public override void Draw(CGRect rect)
{
base.Draw(rect);
using (var gctx = UIGraphics.GetCurrentContext())
{
var pathStatus = new CGPath ();
pathStatus.AddArc(rect.GetMidX(), rect.GetMidY(), (rect.Width>rect.Height?rect.Height/2:rect.Width/2)/2,
1.5f* (float)Math.PI, this.angle * (float)Math.PI+1.5f* (float)Math.PI, false);
gctx.SetLineWidth (rect.Width>rect.Height?rect.Height/2:rect.Width/2);
gctx.SetStrokeColor (color);
gctx.AddPath (pathStatus);
gctx.DrawPath (CGPathDrawingMode.Stroke);
}
}
示例5: PlanetNode
public PlanetNode (CGPoint initialPosition, float size = defaultSize)
{
var path = new CGPath ();
path.AddArc (0, 0, size, 0, (float)Math.PI * 2f, true);
Path = path;
StrokeColor = UIColor.Clear;
FillColor = UIColor.Green;
Position = initialPosition;
// use a local variable to avoid multiple virtual call to the `PhysicsBody` property
var body = SKPhysicsBody.CreateCircularBody (size);
body.CategoryBitMask = Category.Planet;
body.CollisionBitMask = Category.Planet | Category.Edge;
body.ContactTestBitMask = 0;
PhysicsBody = body;
}
示例6: AsteroidNode
public AsteroidNode(PointF initialPosition, float size = defaultSize)
{
var path = new CGPath ();
path.AddArc (0, 0, size, 0, (float)Math.PI * 2f, true);
Path = path;
StrokeColor = UIColor.Clear;
FillColor = UIColor.Brown;
Position = initialPosition;
// use a local variable to avoid multiple virtual call to the `PhysicsBody` property
var body = SKPhysicsBody.BodyWithCircleOfRadius (size);
body.CategoryBitMask = Category.Asteroid;
body.CollisionBitMask = Category.Ship | Category.Asteroid | Category.Edge;
body.ContactTestBitMask = Category.Planet;
PhysicsBody = body;
}
示例7: CustomLayerBasedView
public CustomLayerBasedView (CGRect rect) : base (rect)
{
WantsLayer = true;
CAShapeLayer shapeLayer = new CAShapeLayer ();
// Create a circle path
CGPath path = new CGPath ();
path.AddArc (rect.Width / 2, rect.Height / 2, (rect.Height / 2) - 10, (float)(-(Math.PI / 2)), (float)(3 * Math.PI / 2), false);
shapeLayer.Path = path;
shapeLayer.Position = new CGPoint (Bounds.Width / 2, Bounds.Height / 2);
shapeLayer.FillColor = NSColor.LightGray.CGColor;
shapeLayer.StrokeColor = NSColor.Blue.CGColor;
shapeLayer.LineWidth = 2;
Layer = shapeLayer;
}
示例8: DrawInContext
public override void DrawInContext (CoreGraphics.CGContext ctx)
{
CGRect rect = this.BoundsRect();
CGColorSpace colorSpace = CGColorSpace.CreateDeviceRGB ();
nfloat [] colors = new nfloat[] {
0.42f, 0.66f, 0.31f, 1.0f,
0.95f, 0.76f, 0.20f, 1.0f,
0.80f, 0.25f, 0.15f, 1.0f
};
CGGradient gradient = new CGGradient (colorSpace, colors, null);
nuint tickSpaces = this.Axis.MajorTickCount - 1;
nuint pointsCount = 5;
if (this.Chart.Frame.Size.Height < this.Chart.Frame.Size.Width) {
pointsCount = 3;
}
nfloat diameter = 8;
nfloat spaceHeight = rect.Size.Height / tickSpaces;
nfloat spacing = (spaceHeight - (pointsCount * diameter)) / (pointsCount + 1);
nuint allPointsCount = pointsCount * tickSpaces;
CGPath multipleCirclePath = new CGPath ();
double y = rect.GetMinY() + diameter / 2.0f + spacing;
for (uint i = 1; i <= allPointsCount; i++) {
CGPoint center = new CGPoint (rect.GetMidX (), y);
CGPath path = new CGPath ();
path.AddArc (center.X, center.Y, (nfloat)diameter/2.0f, 0, (nfloat)Math.PI * 2, true);
multipleCirclePath.AddPath (path);
y += spacing + diameter;
if (i % pointsCount == 0) {
y += spacing;
}
}
ctx.SaveState ();
ctx.AddPath (multipleCirclePath);
ctx.Clip ();
CGPoint startPoint = new CGPoint (rect.GetMidX (), rect.GetMinY ());
CGPoint endPoint = new CGPoint (rect.GetMidX (), rect.GetMaxY());
ctx.DrawLinearGradient (gradient, startPoint, endPoint, 0);
ctx.RestoreState ();
base.DrawInContext (ctx);
}
示例9: DrawGraph
public void DrawGraph(CGContext g,nfloat x0,nfloat y0)
{
g.SetLineWidth (_lineWidth);
// Draw background circle
CGPath path = new CGPath ();
_backColor.SetStroke ();
path.AddArc (x0, y0, _radius, 0, 2.0f * (float)Math.PI, true);
g.AddPath (path);
g.DrawPath (CGPathDrawingMode.Stroke);
// Draw overlay circle
var pathStatus = new CGPath ();
_frontColor.SetStroke ();
pathStatus.AddArc(x0, y0, _radius, 0, _degrees * (float)Math.PI, false);
g.AddPath (pathStatus);
g.DrawPath (CGPathDrawingMode.Stroke);
}
示例10: DrawThatMesmerizingThing
private void DrawThatMesmerizingThing ()
{
using (var ctx = UIGraphics.GetCurrentContext ())
{
ctx.SetLineWidth (8);
UIColor.White.SetFill ();
UIColor.Black.SetStroke ();
for (var x = 0; x < 10; x++)
{
var path = new CGPath ();
path.AddArc (Frame.GetMidX (), Frame.GetMidY (), Dimensions[x].R, (nfloat)(Dimensions[x].Et * Math.PI), (nfloat)(Dimensions[x].St * Math.PI), false);
ctx.AddPath (path);
}
ctx.DrawPath (CGPathDrawingMode.FillStroke);
}
}
示例11: Draw
public override void Draw(CGRect rect)
{
base.Draw(rect);
using (CGContext g = UIGraphics.GetCurrentContext())
{
// Set up drawing attributes
g.SetLineWidth(1);
UIColor.Red.SetStroke();
// Set up the drawing path
var path = new CGPath();
path.AddArc(_center.X, _center.Y, _radius, 0.0F, 2 * ((float)Math.PI), false);
// Add path to context and draw
g.AddPath(path);
g.DrawPath(CGPathDrawingMode.Stroke);
}
}
示例12: Draw
public override void Draw(CGRect rect)
{
base.Draw(rect);
//get graphics context
using (var g = UIGraphics.GetCurrentContext())
{
// set up drawing attributes
g.SetLineWidth(10.0f);
UIColor.Green.SetFill();
UIColor.Blue.SetStroke();
// create geometry
var path = new CGPath();
path.AddArc(Bounds.GetMidX(), Bounds.GetMidY(), 50f, 0, 2.0f * (float)Math.PI, true);
// add geometry to graphics context and draw
g.AddPath(path);
g.DrawPath(CGPathDrawingMode.FillStroke);
}
}
示例13: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
// draw a new banana image
addBanana.TouchUpInside += delegate {
// create a graphics context with an in memory bitmap backing store
UIGraphics.BeginImageContext (new SizeF (100.0f, 100.0f));
// get graphics context
CGContext gctx = UIGraphics.GetCurrentContext ();
// set up drawing attributes
gctx.SetLineWidth (5);
UIColor.Brown.SetStroke ();
UIColor.Yellow.SetFill ();
// create geometry
var path = new CGPath ();
path.AddArc (0, 0, 50, 0, (float)Math.PI / 2, false);
path.CloseSubpath ();
// add geometry to graphics context and draw it
gctx.AddPath (path);
gctx.DrawPath (CGPathDrawingMode.FillStroke);
// get a UIImage from the context
UIImage bananaImage = UIGraphics.GetImageFromCurrentImageContext ();
// clean up
UIGraphics.EndImageContext ();
// use the UIImage
iv.Image = bananaImage;
};
}
示例14: ObserveValue
//.........这里部分代码省略.........
_lastOffset = offset; // line 260
bool triggered = false;
CGPath path = new CGPath();
// calculate some useful points and values
float verticalShift = (float)Math.Max(0, -1 * ((kMaxTopRadius + kMaxBottomRadius + kMaxTopPadding + kMaxBottomPadding) + offset));
float distance = (float)Math.Min(kMaxDistance, (float)Math.Abs(verticalShift));
float percentage = 1 - (distance / kMaxDistance);
float currentTopPadding = lerp(kMinTopPadding, kMaxTopPadding, percentage);
float currentTopRadius = lerp(kMinTopRadius, kMaxTopRadius, percentage);
float currentBottomRadius = lerp(kMinBottomRadius, kMaxBottomRadius, percentage);
float currentBottomPadding = lerp(kMinBottomPadding, kMaxBottomPadding, percentage);
PointF bottomOrigin = new PointF((float)Math.Floor(this.Bounds.Size.Width / 2), this.Bounds.Size.Height - currentBottomPadding - currentBottomRadius);
PointF topOrigin = PointF.Empty;
if (distance == 0)
{
topOrigin = new PointF((float)Math.Floor(this.Bounds.Size.Width / 2), bottomOrigin.Y);
}
else
{
topOrigin = new PointF((float)Math.Floor(this.Bounds.Size.Width / 2), this.Bounds.Size.Height + offset + currentTopPadding + currentTopRadius);
if (percentage == 0)
{
bottomOrigin.Y -= (float)Math.Abs(verticalShift) - kMaxDistance;
triggered = true;
}
}
// top semicircle
path.AddArc(topOrigin.X, topOrigin.Y, currentTopRadius, 0, (float)Math.PI, true);
// left curve
PointF leftCp1 = new PointF(lerp((topOrigin.X - currentTopRadius), (bottomOrigin.X - currentBottomRadius), 0.1f), lerp(topOrigin.Y, bottomOrigin.Y, 0.2f));
PointF leftCp2 = new PointF(lerp((topOrigin.X - currentTopRadius), (bottomOrigin.X - currentBottomRadius), 0.9f), lerp(topOrigin.Y, bottomOrigin.Y, 0.2f));
PointF leftDestination = new PointF(bottomOrigin.X - currentBottomRadius, bottomOrigin.Y);
path.AddCurveToPoint(leftCp1, leftCp2, leftDestination);
// bottom semicircle
path.AddArc(bottomOrigin.X, bottomOrigin.Y, currentBottomRadius, (float)Math.PI, 0, true);
// right curve
PointF rightCp2 = new PointF(lerp((topOrigin.X + currentTopRadius), (bottomOrigin.X + currentBottomRadius), 0.1f), lerp(topOrigin.Y, bottomOrigin.Y, 0.2f));
PointF rightCp1 = new PointF(lerp((topOrigin.X + currentTopRadius), (bottomOrigin.X + currentBottomRadius), 0.9f), lerp(topOrigin.Y, bottomOrigin.Y, 0.2f));
PointF rightDestination = new PointF(bottomOrigin.X + currentTopRadius, topOrigin.Y);
path.AddCurveToPoint (rightCp1, rightCp2, rightDestination);
path.CloseSubpath();
if (!triggered) // line 309
{
// set paths
_shapeLayer.Path = path;
_shapeLayer.ShadowPath = path;
// add the arrow shape
float currentArrowSize = lerp(kMinArrowSize, kMaxArrowSize, percentage);
float currentArrowRadius = lerp(kMinArrowRadius, kMaxArrowRadius, percentage);
float arrowBigRadius = currentArrowRadius + (currentArrowSize / 2);
float arrowSmallRadius = currentArrowRadius - (currentArrowSize / 2);
CGPath arrowPath = new CGPath();
/*
示例15: NewBadgePathForTextSize
private CGPath NewBadgePathForTextSize(SizeF size)
{
float arcRadius = (float)Math.Ceiling((size.Height + this.Pad) / 2.0f);
float badgeWidthAdjustment = size.Width - (size.Height / 2.0f);
float badgeWidth = 2.0f * arcRadius;
if (badgeWidthAdjustment > 0.0)
{
badgeWidth += badgeWidthAdjustment;
}
CGPath badgePath = new CGPath();
var m_pi_2 = (float)(Math.PI / 2);
badgePath.MoveToPoint(arcRadius, 0.0f);
badgePath.AddArc(arcRadius, arcRadius, arcRadius, 3.0f * m_pi_2, m_pi_2, true);
badgePath.AddLineToPoint(badgeWidth - arcRadius, 2.0f * arcRadius);
badgePath.AddArc(badgeWidth - arcRadius, arcRadius, arcRadius, m_pi_2, 3.0f * m_pi_2, true);
badgePath.AddLineToPoint(arcRadius, 0.0f);
return badgePath;
}