本文整理汇总了C#中CGPath.AddLineToPoint方法的典型用法代码示例。如果您正苦于以下问题:C# CGPath.AddLineToPoint方法的具体用法?C# CGPath.AddLineToPoint怎么用?C# CGPath.AddLineToPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGPath
的用法示例。
在下文中一共展示了CGPath.AddLineToPoint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: Draw
public override void Draw (CGRect rect)
{
WeatherForecastAnnotation annotation;
CGPath path;
base.Draw (rect);
annotation = Annotation as WeatherForecastAnnotation;
if (annotation == null)
return;
// Get the current graphics context
using (var context = UIGraphics.GetCurrentContext ()) {
context.SetLineWidth (1.0f);
// Draw the gray pointed shape:
path = new CGPath ();
path.MoveToPoint (14.0f, 0.0f);
path.AddLineToPoint (0.0f, 0.0f);
path.AddLineToPoint (55.0f, 50.0f);
context.AddPath (path);
context.SetFillColor (UIColor.LightGray.CGColor);
context.SetStrokeColor (UIColor.Gray.CGColor);
context.DrawPath (CGPathDrawingMode.FillStroke);
// Draw the cyan rounded box
path = new CGPath ();
path.MoveToPoint (15.0f, 0.5f);
path.AddArcToPoint (59.5f, 00.5f, 59.5f, 05.0f, 5.0f);
path.AddArcToPoint (59.5f, 69.5f, 55.5f, 69.5f, 5.0f);
path.AddArcToPoint (10.5f, 69.5f, 10.5f, 64.0f, 5.0f);
path.AddArcToPoint (10.5f, 00.5f, 15.5f, 00.5f, 5.0f);
context.AddPath (path);
context.SetFillColor (UIColor.Cyan.CGColor);
context.SetStrokeColor (UIColor.Blue.CGColor);
context.DrawPath (CGPathDrawingMode.FillStroke);
// Create the location & temperature string
WeatherForecast forecast = annotation.Forecast;
NSString temperature = new NSString (string.Format ("{0}\n{1} / {2}", forecast.Place, forecast.High, forecast.Low));
// Draw the text in black
UIColor.Black.SetColor ();
temperature.DrawString (new CGRect (15.0f, 5.0f, 50.0f, 40.0f), UIFont.SystemFontOfSize (11.0f));
temperature.Dispose ();
// Draw the icon for the weather condition
string imageName = string.Format ("WeatherMap.WeatherIcons.{0}.png", forecast.Condition);
UIImage image = UIImage.FromResource (typeof(WeatherAnnotationView).Assembly, imageName);
image.Draw (new CGRect (12.5f, 28.0f, 45.0f, 45.0f));
image.Dispose ();
}
}
示例3: GetCurrentWavePath
CGPath GetCurrentWavePath ()
{
var path = new CGPath ();
path.MoveToPoint (0, waterWaveHeight);
nfloat y = 0.0f;
for (float x = 0.0f; x <= waterWaveWidth; x++) {
y = WaveAmplitude * (float)Math.Sin ((360 / waterWaveWidth) * (x * Math.PI / 180) - offsetX * Math.PI / 180) + waterWaveHeight;
path.AddLineToPoint (x, y);
}
path.AddLineToPoint (waterWaveWidth, Frame.Height);
path.AddLineToPoint (0, Frame.Height);
path.CloseSubpath ();
return path;
}
示例4: ShipSprite
public ShipSprite(PointF initialPosition)
: base(NSBundle.MainBundle.PathForResource ("spaceship", "png"))
{
CGPath boundingPath = new CGPath ();
boundingPath.MoveToPoint (-12f, -38f);
boundingPath.AddLineToPoint (12f, -38f);
boundingPath.AddLineToPoint (9f, 18f);
boundingPath.AddLineToPoint (2f, 38f);
boundingPath.AddLineToPoint (-2f, 38f);
boundingPath.AddLineToPoint (-9f, 18f);
boundingPath.AddLineToPoint (-12f, -38f);
#if false
// Debug overlay
SKShapeNode shipOverlayShape = new SKShapeNode () {
Path = boundingPath,
StrokeColor = UIColor.Clear,
FillColor = UIColor.FromRGBA (0f, 1f, 0f, 0.5f)
};
ship.AddChild (shipOverlayShape);
#endif
var body = SKPhysicsBody.BodyWithPolygonFromPath (boundingPath);
body.CategoryBitMask = Category.Ship;
body.CollisionBitMask = Category.Ship | Category.Asteroid | Category.Planet | Category.Edge;
body.ContactTestBitMask = body.CollisionBitMask;
body.LinearDamping = 0;
body.AngularDamping = 0.5f;
PhysicsBody = body;
Position = initialPosition;
}
示例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.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);
}
示例6: Draw
public override void Draw(RectangleF rect)
{
base.Draw (rect);
float midY = this.Bounds.Height / 2f;
float right = this.Bounds.Width;
float bottom = this.Bounds.Height;
var ctx = UIGraphics.GetCurrentContext();
ctx.SaveState();
CGPath path = new CGPath();
path.MoveToPoint(new PointF(right, 0f));
path.AddLineToPoint(2f, midY);
path.AddLineToPoint(right, bottom);
ctx.AddPath(path);
ctx.SetStrokeColor(UIColor.Black.CGColor);
ctx.SetLineWidth(2f);
ctx.SetLineCap(CGLineCap.Round);
ctx.StrokePath();
ctx.RestoreState();
ctx.Dispose();
path.Dispose();
}
示例7: createPathForPoints
CGPath createPathForPoints (NSDictionary[] points)
{
CGPath path = new CGPath ();
PointF point;
if (points.Length > 0) {
points [0].ToPoint (out point);
path.MoveToPoint (point);
int i = 1;
while (i < points.Length) {
points [i].ToPoint (out point);
path.AddLineToPoint (point);
i++;
}
path.CloseSubpath ();
}
return path;
}
示例8: createPathForPoints
CGPath createPathForPoints (CGPoint[] points)
{
CGPath path = new CGPath ();
CGPoint point;
if (points.Length > 0) {
point = points [0];
path.MoveToPoint (point);
int i = 1;
while (i < points.Length) {
point = points [i];
path.AddLineToPoint (point);
i++;
}
path.CloseSubpath ();
}
return path;
}
示例9: polyPath
public CGPath polyPath(MKPolyline polyline,MKMapRect mapRect, float zoomScale, CGContext context)
{
MKMapPoint[] points = polyline.Points;
Int32 pointCount = polyline.PointCount;
Int32 i;
if (pointCount < 3)
return null;
CGPath path = new CGPath ();
PointF relativePoint = this.PointForMapPoint (points[0]);
path.MoveToPoint (relativePoint.X, relativePoint.Y);
for (i = 1; i < pointCount; i++)
{
relativePoint = this.PointForMapPoint (points[i]);
path.AddLineToPoint(relativePoint);
}
return path;
}
示例10: ShipSprite
public ShipSprite (CGPoint initialPosition)
: base (NSBundle.MainBundle.PathForResource ("spaceship", "png"))
{
health = startingShipHealth;
using (CGPath boundingPath = new CGPath ()) {
boundingPath.MoveToPoint (-12f, -38f);
boundingPath.AddLineToPoint (12f, -38f);
boundingPath.AddLineToPoint (9f, 18f);
boundingPath.AddLineToPoint (2f, 38f);
boundingPath.AddLineToPoint (-2f, 38f);
boundingPath.AddLineToPoint (-9f, 18f);
boundingPath.AddLineToPoint (-12f, -38f);
#if false
// Debug overlay
SKShapeNode shipOverlayShape = new SKShapeNode () {
Path = boundingPath,
StrokeColor = UIColor.Clear,
FillColor = UIColor.FromRGBA (0f, 1f, 0f, 0.5f)
};
ship.AddChild (shipOverlayShape);
#endif
var body = SKPhysicsBody.CreateBodyFromPath (boundingPath);
body.CategoryBitMask = Category.Ship;
body.CollisionBitMask = Category.Ship | Category.Asteroid | Category.Planet | Category.Edge;
body.ContactTestBitMask = body.CollisionBitMask;
// The ship doesn't slow down when it moves forward, but it does slow its angular rotation. In practice,
// this feels better for a game.
body.LinearDamping = 0;
body.AngularDamping = 0.5f;
PhysicsBody = body;
}
Position = initialPosition;
}
示例11: MakeInfinite
// public bool IsInfinite(Graphics g)
// {
// }
public void MakeInfinite()
{
regionObject = infinite;
var path = RectangleToPath (infinite);
// clear out our containers.
regionList.Clear ();
solution.Clear ();
solution.Add (path);
regionList.Add (new RegionEntry (RegionType.Infinity, infinite, path));
regionPath = new CGPath ();
regionPath.MoveToPoint (infinite.Left, infinite.Top);
regionPath.AddLineToPoint (infinite.Right, infinite.Top);
regionPath.AddLineToPoint (infinite.Right, infinite.Bottom);
regionPath.AddLineToPoint (infinite.Left, infinite.Bottom);
regionBounds = regionPath.BoundingBox.ToRectangleF ();
}
示例12: ObserveValue
//.........这里部分代码省略.........
// 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();
/*
arrowPath.AddArc(topOrigin.X, topOrigin.Y, arrowBigRadius, 0, 3 * (float)Math.PI, false);
arrowPath.AddLineToPoint(topOrigin.X, topOrigin.Y - arrowBigRadius - currentArrowSize);
arrowPath.AddLineToPoint(topOrigin.X + (2 * currentArrowSize), topOrigin.Y - arrowBigRadius + (currentArrowSize / 2));
arrowPath.AddLineToPoint(topOrigin.X, topOrigin.Y - arrowBigRadius + (2 * currentArrowSize));
arrowPath.AddLineToPoint(topOrigin.X, topOrigin.Y - arrowBigRadius + currentArrowSize);
arrowPath.AddArc(topOrigin.X, topOrigin.Y, arrowSmallRadius, 3 * (float)Math.PI, 0, true);
*/
arrowPath.AddArc (topOrigin.X, topOrigin.Y, arrowBigRadius, 0, 3 * (float) Math.PI / 2.0f, false);
arrowPath.AddLineToPoint (topOrigin.X, topOrigin.Y - arrowBigRadius - currentArrowSize);
arrowPath.AddLineToPoint (topOrigin.X + (2 * currentArrowSize), topOrigin.Y - arrowBigRadius + (currentArrowSize / 2.0f));
arrowPath.AddLineToPoint (topOrigin.X, topOrigin.Y - arrowBigRadius + (2 * currentArrowSize));
arrowPath.AddLineToPoint (topOrigin.X, topOrigin.Y - arrowBigRadius + currentArrowSize);
arrowPath.AddArc (topOrigin.X, topOrigin.Y, arrowSmallRadius, 3 * (float) Math.PI / 2.0f, 0, true);
arrowPath.CloseSubpath();
_arrowLayer.Path = arrowPath;
_arrowLayer.FillRule = CAShapeLayer.FillRuleEvenOdd;
arrowPath.Dispose();
// add the highlight shape
CGPath highlightPath = new CGPath();
highlightPath.AddArc(topOrigin.X, topOrigin.Y, currentTopRadius, 0, (float)Math.PI, true);
highlightPath.AddArc(topOrigin.X, topOrigin.Y + 1.25f, currentTopRadius, (float)Math.PI, 0, false);
_highlightLayer.Path = highlightPath;
_highlightLayer.FillRule = CAShapeLayer.FillRuleNonZero;
highlightPath.Dispose();
}
else
{
// start the shape disappearance animation
float radius = lerp(kMinBottomRadius, kMaxBottomRadius, 0.2f);
CABasicAnimation pathMorph = CABasicAnimation.FromKeyPath("path");
pathMorph.Duration = 0.15f;
示例13: CreateBackgroundNode
/// <summary>
/// Helper method that creates the grid shown in the background of the scene.
/// </summary>
/// <returns>The background node.</returns>
/// <param name="size">Size of the scene.</param>
/// <param name="height">Height of the scene.</param>
static SKNode CreateBackgroundNode(SizeF size)
{
// Use a SKShapeNode. This can display any arbitrary CG content.
var shapeNode = new SKShapeNode ();
var path = new CGPath();
shapeNode.StrokeColor = UIColor.FromRGB (112, 80, 160);
float cellSize = 32f;
// Draw vertical lines.
float x = 0f;
do
{
path.MoveToPoint (x, 0);
path.AddLineToPoint (x, size.Height);
x += cellSize;
} while(x < size.Width);
// Draw horizontal lines.
float y = 0f;
do
{
path.MoveToPoint (0, y);
path.AddLineToPoint (size.Width, y);
y += cellSize;
} while(y < size.Height);
shapeNode.Path = path;
return shapeNode;
}
示例14: Close
private void Close()
{
if (flag == -1)
{
this.isAnimating = false;
this.timer.Invalidate();
this.timer = null;
return;
}
int tag = 1000 + flag;
MenuItem item = this.GetByTag(tag);
item.Selected -= this.ItemSelected;
var rotateAnimation = (CAKeyFrameAnimation)CAKeyFrameAnimation.FromKeyPath("transform.rotation.z");
rotateAnimation.Values = new NSNumber[] {0f, this.CloseRotation, 0f};
rotateAnimation.Duration = 0.5f;
rotateAnimation.KeyTimes = new NSNumber[] {0f, 0.4f, 0.5f};
var positionAnimation = (CAKeyFrameAnimation)CAKeyFrameAnimation.FromKeyPath("position");
positionAnimation.Duration = 0.5f;
var path = new CGPath();
path.MoveToPoint(item.EndPoint.X, item.EndPoint.Y);
path.AddLineToPoint(item.FarPoint.X, item.FarPoint.Y);
path.AddLineToPoint(item.StartPoint.X, item.StartPoint.Y);
positionAnimation.Path = path;
var alphaAnimation = (CAKeyFrameAnimation)CAKeyFrameAnimation.FromKeyPath("opacity");
alphaAnimation.Values = new NSNumber[] {1f, 1f, 0f};
alphaAnimation.Duration = 0.5f;
alphaAnimation.KeyTimes = new NSNumber[] {0f, 0.8f, 1f};
var animationGroup = new CAAnimationGroup();
animationGroup.Animations = new[] { positionAnimation, rotateAnimation, alphaAnimation };
animationGroup.Duration = 0.5f;
animationGroup.FillMode = CAFillMode.Forwards;
animationGroup.TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseIn);
item.Layer.AddAnimation(animationGroup, "Close");
item.Alpha = 0f;
item.Center = item.StartPoint;
flag--;
}
示例15: Draw
public override void Draw (RectangleF rect)
{
//base.Draw (rect);
float radius = 7.0f;
float stroke = 1.0f;
var context = UIGraphics.GetCurrentContext ();
rect.Size.Width -= stroke + 14f;
rect.Size.Height -= stroke + CalloutMapAnnotationViewHeightAboveParent
- offsetFromParent.Y + CalloutMapAnnotationViewBottomShadowBufferSize;
rect.Location.X += stroke / 2.0f + 7.0f;
rect.Location.Y += stroke / 2.0f;
SizeF size = new SizeF(rect.Size);
size.Height -= 8;
var path = new CGPath ();
path.MoveToPoint (rect.Location.X, rect.Location.Y + radius);
path.AddLineToPoint(rect.Location.X, rect.Location.Y + size.Height - radius);
path.AddArc (rect.Location.X + radius, rect.Location.Y + size.Height - radius,
radius, (float)Math.PI, (float)Math.PI / 2.0f, true);
/*
*
*
*
*/
path.AddArc(rect.Location.X + rect.Size.Width - radius, rect.Location.Y + size.Height - radius,
radius, (float)Math.PI / 2.0f, 0.0f, true);
path.AddLineToPoint(rect.Location.X + size.Width, rect.Location.Y + radius);
path.AddArc(rect.Location.X + size.Width - radius, rect.Location.Y + radius,
radius, 0.0f, - (float)Math.PI / 2.0f, true);
path.AddLineToPoint(rect.Location.X + radius, rect.Location.Y);
path.AddArc(rect.Location.X + radius, rect.Location.Y + radius, radius,
- (float)Math.PI / 2.0f, (float)Math.PI, true);
path.CloseSubpath ();
float red, green, blue, alpha;
UIColor.Black.GetRGBA(out red, out green, out blue, out alpha);
UIColor color = UIColor.FromRGBA(red, green, blue, .6f);
color.SetFill();
var bounds = Bounds;
var b = new SizeF(16, 8);
context.MoveTo ((bounds.Width - b.Width) / 2 - 8, bounds.Height - 2 - b.Height);
context.AddLineToPoint (bounds.Width/2 - 8, bounds.Height - 2);
context.AddLineToPoint ((bounds.Width + b.Width) / 2 - 8, bounds.Height - b.Height - 2);
context.ClosePath ();
context.AddPath(path);
context.SaveState();
context.SetShadowWithColor (new SizeF (0, yShadowOffset), 6, UIColor.FromWhiteAlpha(0.0f, 0.5f).CGColor);
context.FillPath();
context.RestoreState();
if (Annotation is CalloutMapAnnotation)
{
var annotation = (Annotation as CalloutMapAnnotation);
blocks = new List<Block>();
GetSize(annotation, blocks, bounds);
foreach (Block block in blocks)
{
if (block.Type == BlockType.Text)
{
block.TextColor.SetColor();
if (block.LineBreakMode.HasValue)
DrawString (block.Value, block.Bounds, block.Font, block.LineBreakMode.Value, UITextAlignment.Left);
else
DrawString (block.Value, block.Bounds, block.Font);
}
}
}
}