public static CAShapeLayer ToShape(this LinePath element) { var line = new CAShapeLayer(); var bezierPath = new NSBezierPath(); bezierPath.MoveTo(new CGPoint(element.X1, element.Y1)); bezierPath.LineTo(new CGPoint(element.X2, element.Y2)); line.Path = bezierPath.ToCGPath(); if (!string.IsNullOrEmpty(element.Stroke)) { line.StrokeColor = XExtensions.ConvertToNSColor(element.Stroke).CGColor; } if (!string.IsNullOrEmpty(element.Fill)) { line.FillColor = XExtensions.ConvertToNSColor(element.Fill).CGColor; } line.LineWidth = element.StrokeWidth; var width = Math.Max(element.X1, element.X2) - Math.Min(element.X1, element.X2); var height = Math.Max(element.Y1, element.Y2) - Math.Min(element.Y1, element.Y2); line.Bounds = new CGRect(0, 0, width, height); return(line); }
public static CAShapeLayer ToShape(this CirclePath element) { var shape = new CAShapeLayer(); var bezierPath = NSBezierPath.FromOvalInRect(new CGRect(0, 0, element.Radio * 2, element.Radio * 2)); shape.Path = bezierPath.ToCGPath(); if (!string.IsNullOrEmpty(element.Stroke)) { shape.StrokeColor = XExtensions.ConvertToNSColor(element.Stroke).CGColor; } shape.LineWidth = element.StrokeWidth; if (!string.IsNullOrEmpty(element.Fill)) { shape.FillColor = XExtensions.ConvertToNSColor(element.Fill).CGColor; } var diameter = element.Radio * 2; shape.Bounds = new CGRect(0, 0, diameter, diameter); return(shape); }
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); }
public static CAShapeLayer ToShape(this Path element) { var shape = new CAShapeLayer(); if (!string.IsNullOrEmpty(element.d)) { shape.Path = PathBuilder.Build(element.d); } 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; return(shape); }