/// <summary> /// Initializes a new instance of the <see cref="Rectangle" /> class. /// </summary> /// <param name="topLeft">The top left.</param> /// <param name="bottomRight">The bottom right.</param> public Rectangle(Vector2 topLeft, Vector2 bottomRight) { this.Location = topLeft; this.topLeft = topLeft; this.bottomRight = bottomRight; this.Size = new Size(bottomRight.X - topLeft.X, bottomRight.Y - topLeft.Y); this.points = ImmutableArray.Create(new Vector2[4] { this.topLeft, new Vector2(this.bottomRight.X, this.topLeft.Y), this.bottomRight, new Vector2(this.topLeft.X, this.bottomRight.Y) }); this.halfLength = this.Size.Width + this.Size.Height; this.length = this.halfLength * 2; this.path = new RectanglePath(this); this.pathCollection = ImmutableArray.Create <IPath>(this.path); }
public static CAShapeLayer ToShape(this RectanglePath element) { var shape = new CAShapeLayer(); var bezierPath = NSBezierPath.FromRect(new CGRect(0, 0, element.Width, element.Height)); shape.Path = bezierPath.ToCGPath(); if (!string.IsNullOrEmpty(element.Stroke)) { shape.StrokeColor = XExtensions.ConvertToNSColor(element.Stroke).CGColor; } if (!string.IsNullOrEmpty(element.Fill)) { shape.FillColor = XExtensions.ConvertToNSColor(element.Fill).CGColor; } shape.LineWidth = element.StrokeWidth * 2; shape.Bounds = new CGRect(0, 0, element.Width, element.Height); return(shape); }