本文整理汇总了C#中CGPath.MoveToPoint方法的典型用法代码示例。如果您正苦于以下问题:C# CGPath.MoveToPoint方法的具体用法?C# CGPath.MoveToPoint怎么用?C# CGPath.MoveToPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGPath
的用法示例。
在下文中一共展示了CGPath.MoveToPoint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例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: 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 ();
}
}
示例4: MakeRoundedPath
internal static CGPath MakeRoundedPath(float size)
{
float hsize = size/2;
var path = new CGPath ();
path.MoveToPoint (size, hsize);
path.AddArcToPoint (size, size, hsize, size, 4);
path.AddArcToPoint (0, size, 0, hsize, 4);
path.AddArcToPoint (0, 0, hsize, 0, 4);
path.AddArcToPoint (size, 0, size, hsize, 4);
path.CloseSubpath ();
return path;
}
示例5: MakeRoundedPath
public static CGPath MakeRoundedPath(float size, float radius)
{
float hsize = size / 2;
var path = new CGPath();
path.MoveToPoint(size, hsize);
path.AddArcToPoint(size, size, hsize, size, radius);
path.AddArcToPoint(0, size, 0, hsize, radius);
path.AddArcToPoint(0, 0, hsize, 0, radius);
path.AddArcToPoint(size, 0, size, hsize, radius);
path.CloseSubpath();
return path;
}
示例6: 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;
}
示例7: MakeRoundedRectPath
/// <summary>
/// Creates a path for a rectangle with rounded corners
/// </summary>
/// <param name="rect">
/// The <see cref="CGRect"/> rectangle bounds
/// </param>
/// <param name="radius">
/// The <see cref="System.Single"/> size of the rounded corners
/// </param>
/// <returns>
/// A <see cref="CGPath"/> that can be used to stroke the rounded rectangle
/// </returns>
public static CGPath MakeRoundedRectPath(CGRect rect, float radius)
{
nfloat minx = rect.Left;
nfloat midx = rect.Left + (rect.Width) / 2;
nfloat maxx = rect.Right;
nfloat miny = rect.Top;
nfloat midy = rect.Y + rect.Size.Height / 2;
nfloat maxy = rect.Bottom;
var path = new CGPath();
path.MoveToPoint(minx, midy);
path.AddArcToPoint(minx, miny, midx, miny, radius);
path.AddArcToPoint(maxx, miny, maxx, midy, radius);
path.AddArcToPoint(maxx, maxy, midx, maxy, radius);
path.AddArcToPoint(minx, maxy, minx, midy, radius);
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: 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;
}
示例11: 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);
}
示例12: 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();
}
示例13: 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;
}
示例14: 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;
}
示例15: SetMagnitudes
public void SetMagnitudes (double [] magnitudeData)
{
if (curveLayer == null) {
curveLayer = new CAShapeLayer ();
curveLayer.FillColor = UIColor.FromRGBA (0.31f, 0.37f, 0.73f, 0.8f).CGColor;
graphLayer.AddSublayer (curveLayer);
}
var bezierPath = new CGPath ();
var width = graphLayer.Bounds.Width;
bezierPath.MoveToPoint (leftMargin, graphLayer.Frame.Height + bottomMargin);
float lastDbPos = 0f;
float location = leftMargin;
var frequencyCount = frequencies?.Count ?? 0;
var pixelRatio = (int)(Math.Ceiling (width / frequencyCount));
for (int i = 0; i < frequencyCount; i++) {
var dbValue = 20 * Math.Log10 (magnitudeData [i]);
float dbPos;
if (dbValue < -defaultGain)
dbPos = GetLocationForDbValue (-defaultGain);
else if (dbValue > defaultGain)
dbPos = GetLocationForDbValue (defaultGain);
else
dbPos = GetLocationForDbValue ((float)dbValue);
if (Math.Abs (lastDbPos - dbPos) >= 0.1)
bezierPath.AddLineToPoint (location, dbPos);
lastDbPos = dbPos;
location += pixelRatio;
if (location > width + graphLayer.Frame.X) {
location = (float)width + (float)graphLayer.Frame.X;
break;
}
}
bezierPath.AddLineToPoint (location, graphLayer.Frame.Y + graphLayer.Frame.Height + bottomMargin);
bezierPath.CloseSubpath ();
CATransaction.Begin ();
CATransaction.DisableActions = true;
curveLayer.Path = bezierPath;
CATransaction.Commit ();
UpdateControls (true);
}