LineTo() публичный Метод

public LineTo ( SKPoint point ) : void
point SKPoint
Результат void
Пример #1
0
        private static SKPath ToSkia(IViewport viewport, Polygon polygon)
        {
            var vertices = polygon.ExteriorRing.Vertices;
            var path = new SKPath();
            {
                // todo: use transform matrix
                var first = viewport.WorldToScreen(vertices[0].X, vertices[0].Y);
                path.MoveTo((float)first.X, (float) first.Y);

                for (var i = 1; i < vertices.Count; i++)
                {
                   var point = viewport.WorldToScreen(vertices[i].X, vertices[i].Y);
                    path.LineTo((float) point.X, (float) point.Y);
                }
                path.Close();
                foreach (var interiorRing in polygon.InteriorRings)
                {
                    // note: For Skia inner rings need to be clockwise and outer rings
                    // need to be counter clockwise (if this is the other way around it also
                    // seems to work)
                    // this is not a requirement of the OGC polygon.
                    var firstInner = viewport.WorldToScreen(interiorRing.Vertices[0].X, interiorRing.Vertices[0].Y);
                    path.MoveTo((float)firstInner.X, (float)firstInner.Y);
                    for (var i = 1; i < interiorRing.Vertices.Count; i++)
                    {
                        var point = viewport.WorldToScreen(interiorRing.Vertices[i].X, interiorRing.Vertices[i].Y);
                        path.LineTo((float)point.X, (float)point.Y);
                    }
                }
                path.Close();
                return path;
            }
        }
        static SkiaSharp.SKPath CreatePolygon(PixelFarm.Drawing.PointF[] points)
        {
            SkiaSharp.SKPath p = new SkiaSharp.SKPath();
            int j = points.Length;

            PixelFarm.Drawing.PointF p0 = new PixelFarm.Drawing.PointF();
            for (int i = 0; i < j; ++i)
            {
                if (i == 0)
                {
                    p0 = points[0];
                    p.MoveTo(p0.X, p0.Y);
                }
                else if (i == j - 1)
                {
                    //last one
                    var point = points[i];
                    p.LineTo(point.X, point.Y);
                    p.LineTo(p0.X, p0.Y);
                    p.Close();
                    break;
                }
                else
                {
                    var point = points[i];
                    p.LineTo(point.X, point.Y);
                }
            }
            return(p);
        }
Пример #3
0
        public static SKPath CreateGraphicsPath(VertexStore vxs)
        {
            //render vertice in store
            int vcount = vxs.Count;
            double prevX = 0;
            double prevY = 0;
            double prevMoveToX = 0;
            double prevMoveToY = 0;
            //var brush_path = new System.Drawing.Drawing2D.GraphicsPath(FillMode.Winding);//*** winding for overlapped path
            var brushPath = new SKPath();
            //how to set widening mode 
            for (int i = 0; i < vcount; ++i)
            {
                double x, y;
                PixelFarm.Agg.VertexCmd cmd = vxs.GetVertex(i, out x, out y);
                switch (cmd)
                {
                    case PixelFarm.Agg.VertexCmd.MoveTo:
                        prevMoveToX = prevX = x;
                        prevMoveToY = prevY = y;
                        //brush_path.StartFigure();
                        brushPath.MoveTo((float)x, (float)y);
                        break;
                    case PixelFarm.Agg.VertexCmd.LineTo:
                        //brush_path.AddLine((float)prevX, (float)prevY, (float)x, (float)y);
                        brushPath.LineTo((float)x, (float)y);
                        prevX = x;
                        prevY = y;
                        break;
                    case PixelFarm.Agg.VertexCmd.CloseAndEndFigure:
                        //brush_path.AddLine((float)prevX, (float)prevY, (float)prevMoveToX, (float)prevMoveToY);
                        brushPath.LineTo((float)prevMoveToX, (float)prevMoveToY);

                        prevMoveToX = prevX = x;
                        prevMoveToY = prevY = y;
                        //brush_path.CloseFigure();
                        brushPath.Close();
                        break;
                    case PixelFarm.Agg.VertexCmd.EndFigure:
                        break;
                    case PixelFarm.Agg.VertexCmd.Stop:
                        i = vcount + 1;//exit from loop
                        break;
                    default:
                        throw new NotSupportedException();
                }
            }
            return brushPath;
        }
Пример #4
0
 /// <summary>
 /// we do NOT store vxsSnap
 /// </summary>
 /// <param name="vxsSnap"></param>
 /// <returns></returns>
 public static SKPath CreateGraphicsPath(VertexStoreSnap vxsSnap)
 {
     VertexSnapIter vxsIter = vxsSnap.GetVertexSnapIter();
     double prevX = 0;
     double prevY = 0;
     double prevMoveToX = 0;
     double prevMoveToY = 0;
     //var brush_path = new System.Drawing.Drawing2D.GraphicsPath(FillMode.Winding);//*** winding for overlapped path  
     var brushPath = new SKPath();
     for (;;)
     {
         double x, y;
         VertexCmd cmd = vxsIter.GetNextVertex(out x, out y);
         switch (cmd)
         {
             case PixelFarm.Agg.VertexCmd.MoveTo:
                 prevMoveToX = prevX = x;
                 prevMoveToY = prevY = y;
                 brushPath.MoveTo((float)x, (float)y);
                 break;
             case PixelFarm.Agg.VertexCmd.LineTo:
                 //brushPath.AddLine((float)prevX, (float)prevY, (float)x, (float)y);
                 brushPath.LineTo((float)x, (float)y);
                 prevX = x;
                 prevY = y;
                 break;
             case PixelFarm.Agg.VertexCmd.CloseAndEndFigure:
                 //from current point                         
                 //brushPath.AddLine((float)prevX, (float)prevY, (float)prevMoveToX, (float)prevMoveToY);
                 brushPath.LineTo((float)prevMoveToX, (float)prevMoveToY);
                 prevX = prevMoveToX;
                 prevY = prevMoveToY;
                 //brushPath.CloseFigure();
                 brushPath.Close();
                 break;
             case PixelFarm.Agg.VertexCmd.EndFigure:
                 goto EXIT_LOOP;
             case PixelFarm.Agg.VertexCmd.Stop:
                 goto EXIT_LOOP;
             default:
                 throw new NotSupportedException();
         }
     }
     EXIT_LOOP:
     return brushPath;
 }
Пример #5
0
        private static SKPath ToSkia(List<Point> vertices)
        {
            var points = new SKPath();

            for (var i = 0; i < vertices.Count; i++)
            {
                if (i == 0)
                {
                    points.MoveTo((float)vertices[i].X, (float)vertices[i].Y);
                }
                else
                {
                    points.LineTo((float)vertices[i].X, (float)vertices[i].Y);
                }
            }
            return points;
        }
Пример #6
0
        public static void FilledHeptagram(SKCanvas canvas, int width, int height)
        {
            var size = ((float)height > width ? width : height) * 0.75f;
            var R    = 0.45f * size;
            var TAU  = 6.2831853f;

            using (var path = new SKPath()) {
                path.MoveTo(R, 0.0f);
                for (int i = 1; i < 7; ++i)
                {
                    var theta = 3f * i * TAU / 7f;
                    path.LineTo(R * (float)Math.Cos(theta), R * (float)Math.Sin(theta));
                }
                path.Close();

                using (var paint = new SKPaint()) {
                    paint.IsAntialias = true;
                    canvas.Clear(SKColors.White);
                    canvas.Translate(width / 2f, height / 2f);
                    canvas.DrawPath(path, paint);
                }
            }
        }
Пример #7
0
                #pragma warning restore 414

        public static void DrawXamagon(SKCanvas canvas, int width, int height)
        {
            // Width 41.6587026 => 144.34135
            // Height 56 => 147

            var paddingFactor = .6f;
            var imageLeft     = 41.6587026f;
            var imageRight    = 144.34135f;
            var imageTop      = 56f;
            var imageBottom   = 147f;

            var imageWidth = imageRight - imageLeft;

            var scale = (((float)height > width ? width : height) / imageWidth) * paddingFactor;

            var translateX = (imageLeft + imageRight) / -2 + width / scale * 1 / 2;
            var translateY = (imageBottom + imageTop) / -2 + height / scale * 1 / 2;

            canvas.Scale(scale, scale);
            canvas.Translate(translateX, translateY);


            using (var paint = new SKPaint()) {
                paint.IsAntialias = true;
                paint.Color       = SKColors.White;
                canvas.DrawPaint(paint);

                paint.StrokeCap = SKStrokeCap.Round;
                var t = paint.StrokeCap;


                using (var path = new SKPath()) {
                    path.MoveTo(71.4311121f, 56f);
                    path.CubicTo(68.6763107f, 56.0058575f, 65.9796704f, 57.5737917f, 64.5928855f, 59.965729f);
                    path.LineTo(43.0238921f, 97.5342563f);
                    path.CubicTo(41.6587026f, 99.9325978f, 41.6587026f, 103.067402f, 43.0238921f, 105.465744f);
                    path.LineTo(64.5928855f, 143.034271f);
                    path.CubicTo(65.9798162f, 145.426228f, 68.6763107f, 146.994582f, 71.4311121f, 147f);
                    path.LineTo(114.568946f, 147f);
                    path.CubicTo(117.323748f, 146.994143f, 120.020241f, 145.426228f, 121.407172f, 143.034271f);
                    path.LineTo(142.976161f, 105.465744f);
                    path.CubicTo(144.34135f, 103.067402f, 144.341209f, 99.9325978f, 142.976161f, 97.5342563f);
                    path.LineTo(121.407172f, 59.965729f);
                    path.CubicTo(120.020241f, 57.5737917f, 117.323748f, 56.0054182f, 114.568946f, 56f);
                    path.LineTo(71.4311121f, 56f);
                    path.Close();

                    paint.Color = XamDkBlue;
                    canvas.DrawPath(path, paint);
                }

                using (var path = new SKPath()) {
                    path.MoveTo(71.8225901f, 77.9780432f);
                    path.CubicTo(71.8818491f, 77.9721857f, 71.9440029f, 77.9721857f, 72.0034464f, 77.9780432f);
                    path.LineTo(79.444074f, 77.9780432f);
                    path.CubicTo(79.773437f, 77.9848769f, 80.0929203f, 78.1757336f, 80.2573978f, 78.4623994f);
                    path.LineTo(92.8795281f, 101.015639f);
                    path.CubicTo(92.9430615f, 101.127146f, 92.9839987f, 101.251384f, 92.9995323f, 101.378901f);
                    path.CubicTo(93.0150756f, 101.251354f, 93.055974f, 101.127107f, 93.1195365f, 101.015639f);
                    path.LineTo(105.711456f, 78.4623994f);
                    path.CubicTo(105.881153f, 78.167045f, 106.215602f, 77.975134f, 106.554853f, 77.9780432f);
                    path.LineTo(113.995483f, 77.9780432f);
                    path.CubicTo(114.654359f, 77.9839007f, 115.147775f, 78.8160066f, 114.839019f, 79.4008677f);
                    path.LineTo(102.518299f, 101.500005f);
                    path.LineTo(114.839019f, 123.568869f);
                    path.CubicTo(115.176999f, 124.157088f, 114.671442f, 125.027775f, 113.995483f, 125.021957f);
                    path.LineTo(106.554853f, 125.021957f);
                    path.CubicTo(106.209673f, 125.019028f, 105.873247f, 124.81384f, 105.711456f, 124.507327f);
                    path.LineTo(93.1195365f, 101.954088f);
                    path.CubicTo(93.0560031f, 101.84258f, 93.0150659f, 101.718333f, 92.9995323f, 101.590825f);
                    path.CubicTo(92.983989f, 101.718363f, 92.9430906f, 101.842629f, 92.8795281f, 101.954088f);
                    path.LineTo(80.2573978f, 124.507327f);
                    path.CubicTo(80.1004103f, 124.805171f, 79.7792269f, 125.008397f, 79.444074f, 125.021957f);
                    path.LineTo(72.0034464f, 125.021957f);
                    path.CubicTo(71.3274867f, 125.027814f, 70.8220664f, 124.157088f, 71.1600463f, 123.568869f);
                    path.LineTo(83.4807624f, 101.500005f);
                    path.LineTo(71.1600463f, 79.400867f);
                    path.CubicTo(70.8647037f, 78.86725f, 71.2250368f, 78.0919422f, 71.8225901f, 77.9780432f);
                    path.LineTo(71.8225901f, 77.9780432f);
                    path.Close();

                    paint.Color = SKColors.White;
                    canvas.DrawPath(path, paint);
                }
            }
        }
        static SkiaSharp.SKPath ResolveGraphicsPath(GraphicsPath path)
        {
            //convert from graphics path to internal presentation
            SkiaSharp.SKPath innerPath = path.InnerPath as SkiaSharp.SKPath;
            if (innerPath != null)
            {
                return(innerPath);
            }
            //--------
            innerPath      = new SkiaSharp.SKPath();
            path.InnerPath = innerPath;
            List <float>       points;
            List <PathCommand> cmds;

            GraphicsPath.GetPathData(path, out points, out cmds);
            int j       = cmds.Count;
            int p_index = 0;

            for (int i = 0; i < j; ++i)
            {
                PathCommand cmd = cmds[i];
                switch (cmd)
                {
                default:
                    throw new NotSupportedException();

                case PathCommand.Arc:

                    var oval = SkiaSharp.SKRect.Create(points[p_index],
                                                       points[p_index + 1],
                                                       points[p_index + 2],
                                                       points[p_index + 3]);

                    innerPath.ArcTo(oval,
                                    points[p_index + 4],
                                    points[p_index + 5],
                                    true);
                    p_index += 6;
                    break;

                case PathCommand.Bezier:
                    innerPath.MoveTo(points[p_index]
                                     , points[p_index + 1]);
                    innerPath.CubicTo(
                        points[p_index + 2],
                        points[p_index + 3],
                        points[p_index + 4],
                        points[p_index + 5],
                        points[p_index + 6],
                        points[p_index + 7]);
                    p_index += 8;
                    break;

                case PathCommand.CloseFigure:
                    //?
                    break;

                case PathCommand.Ellipse:

                    innerPath.AddOval(
                        SkiaSharp.SKRect.Create(
                            points[p_index],
                            points[p_index + 1],
                            points[p_index + 2],
                            points[p_index + 3]
                            ));

                    p_index += 4;
                    break;

                case PathCommand.Line:

                    innerPath.MoveTo(points[p_index],
                                     points[p_index + 1]);
                    innerPath.LineTo(
                        points[p_index + 2],
                        points[p_index + 3]);
                    p_index += 4;
                    break;

                case PathCommand.Rect:
                    innerPath.AddRect(
                        SkiaSharp.SKRect.Create(
                            points[p_index],
                            points[p_index + 1],
                            points[p_index + 2],
                            points[p_index + 3]
                            ));
                    p_index += 4;
                    break;

                case PathCommand.StartFigure:
                    break;
                }
            }


            return(innerPath);
        }
		public static void FilledHeptagram (SKCanvas canvas, int width, int height)
		{
			var size = ((float)height > width ? width : height) * 0.75f;
			var R = 0.45f * size;
			var TAU = 6.2831853f;

			using (var path = new SKPath ()) {
				path.MoveTo (R, 0.0f);
				for (int i = 1; i < 7; ++i) {
					var theta = 3f * i * TAU / 7f;
					path.LineTo (R * (float)Math.Cos (theta), R * (float)Math.Sin (theta));
				}
				path.Close ();

				using (var paint = new SKPaint ()) {
					paint.IsAntialias = true;
					canvas.Clear (SKColors.White);
					canvas.Translate (width / 2f, height / 2f);
					canvas.DrawPath (path, paint);
				}
			}
		}
		#pragma warning restore 414

		public static void DrawXamagon (SKCanvas canvas, int width, int height)
		{
			// Width 41.6587026 => 144.34135
			// Height 56 => 147

			var paddingFactor = .6f;
			var imageLeft = 41.6587026f;
			var imageRight = 144.34135f;
			var imageTop = 56f;
			var imageBottom = 147f;

			var imageWidth = imageRight - imageLeft;

			var scale = (((float)height > width ? width : height) / imageWidth) * paddingFactor;

			var translateX =  (imageLeft + imageRight) / -2 + width/scale * 1/2;
			var translateY =  (imageBottom + imageTop) / -2 + height/scale * 1/2;

			canvas.Scale (scale, scale);
			canvas.Translate (translateX , translateY);


			using (var paint = new SKPaint ()) {
				paint.IsAntialias = true;
				paint.Color = SKColors.White;
				canvas.DrawPaint (paint);

				paint.StrokeCap = SKStrokeCap.Round;
				var t = paint.StrokeCap;


				using (var path = new SKPath ()) {
					path.MoveTo (71.4311121f, 56f);
					path.CubicTo (68.6763107f, 56.0058575f, 65.9796704f, 57.5737917f, 64.5928855f, 59.965729f);
					path.LineTo (43.0238921f, 97.5342563f);
					path.CubicTo (41.6587026f, 99.9325978f, 41.6587026f, 103.067402f, 43.0238921f, 105.465744f);
					path.LineTo (64.5928855f, 143.034271f);
					path.CubicTo (65.9798162f, 145.426228f, 68.6763107f, 146.994582f, 71.4311121f, 147f);
					path.LineTo (114.568946f, 147f);
					path.CubicTo (117.323748f, 146.994143f, 120.020241f, 145.426228f, 121.407172f, 143.034271f);
					path.LineTo (142.976161f, 105.465744f);
					path.CubicTo (144.34135f, 103.067402f, 144.341209f, 99.9325978f, 142.976161f, 97.5342563f);
					path.LineTo (121.407172f, 59.965729f);
					path.CubicTo (120.020241f, 57.5737917f, 117.323748f, 56.0054182f, 114.568946f, 56f);
					path.LineTo (71.4311121f, 56f);
					path.Close ();

					paint.Color = XamDkBlue;
					canvas.DrawPath (path, paint);

				}

				using (var path = new SKPath ()) {

					path.MoveTo (71.8225901f, 77.9780432f);
					path.CubicTo (71.8818491f, 77.9721857f, 71.9440029f, 77.9721857f, 72.0034464f, 77.9780432f);
					path.LineTo (79.444074f, 77.9780432f);
					path.CubicTo (79.773437f, 77.9848769f, 80.0929203f, 78.1757336f, 80.2573978f, 78.4623994f);
					path.LineTo (92.8795281f, 101.015639f);
					path.CubicTo (92.9430615f, 101.127146f, 92.9839987f, 101.251384f, 92.9995323f, 101.378901f);
					path.CubicTo (93.0150756f, 101.251354f, 93.055974f, 101.127107f, 93.1195365f, 101.015639f);
					path.LineTo (105.711456f, 78.4623994f);
					path.CubicTo (105.881153f, 78.167045f, 106.215602f, 77.975134f, 106.554853f, 77.9780432f);
					path.LineTo (113.995483f, 77.9780432f);
					path.CubicTo (114.654359f, 77.9839007f, 115.147775f, 78.8160066f, 114.839019f, 79.4008677f);
					path.LineTo (102.518299f, 101.500005f);
					path.LineTo (114.839019f, 123.568869f);
					path.CubicTo (115.176999f, 124.157088f, 114.671442f, 125.027775f, 113.995483f, 125.021957f);
					path.LineTo (106.554853f, 125.021957f);
					path.CubicTo (106.209673f, 125.019028f, 105.873247f, 124.81384f, 105.711456f, 124.507327f);
					path.LineTo (93.1195365f, 101.954088f);
					path.CubicTo (93.0560031f, 101.84258f, 93.0150659f, 101.718333f, 92.9995323f, 101.590825f);
					path.CubicTo (92.983989f, 101.718363f, 92.9430906f, 101.842629f, 92.8795281f, 101.954088f);
					path.LineTo (80.2573978f, 124.507327f);
					path.CubicTo (80.1004103f, 124.805171f, 79.7792269f, 125.008397f, 79.444074f, 125.021957f);
					path.LineTo (72.0034464f, 125.021957f);
					path.CubicTo (71.3274867f, 125.027814f, 70.8220664f, 124.157088f, 71.1600463f, 123.568869f);
					path.LineTo (83.4807624f, 101.500005f);
					path.LineTo (71.1600463f, 79.400867f);
					path.CubicTo (70.8647037f, 78.86725f, 71.2250368f, 78.0919422f, 71.8225901f, 77.9780432f);
					path.LineTo (71.8225901f, 77.9780432f);
					path.Close ();

					paint.Color = SKColors.White;
					canvas.DrawPath (path, paint);
				}
			}
		}
Пример #11
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="xpg"></param>
        /// <param name="dx"></param>
        /// <param name="dy"></param>
        /// <param name="scale"></param>
        /// <returns></returns>
        public static SKPath ToSKPath(this XPathGeometry xpg, double dx, double dy, Func<double, float> scale)
        {
            var path = new SKPath();
            path.FillType = xpg.FillRule == XFillRule.EvenOdd ? SKPathFillType.EvenOdd : SKPathFillType.Winding;

            foreach (var xpf in xpg.Figures)
            {
                var previous = default(XPoint);

                // Begin new figure.
                path.MoveTo(
                    scale(xpf.StartPoint.X + dx),
                    scale(xpf.StartPoint.Y + dy));

                previous = xpf.StartPoint;

                foreach (var segment in xpf.Segments)
                {
                    if (segment is XArcSegment)
                    {
                        var arcSegment = segment as XArcSegment;
                        path.ArcTo(
                            scale(arcSegment.Size.Width),
                            scale(arcSegment.Size.Height), 
                            (float)arcSegment.RotationAngle, 
                            arcSegment.IsLargeArc ? SKPathArcSize.Large : SKPathArcSize.Small,
                            arcSegment.SweepDirection == XSweepDirection.Clockwise ? SKPathDirection.Clockwise : SKPathDirection.CounterClockwise,
                            scale(arcSegment.Point.X + dx),
                            scale(arcSegment.Point.Y + dy));

                        previous = arcSegment.Point;
                    }
                    else if (segment is XCubicBezierSegment)
                    {
                        var cubicBezierSegment = segment as XCubicBezierSegment;
                        path.CubicTo(
                            scale(cubicBezierSegment.Point1.X + dx),
                            scale(cubicBezierSegment.Point1.Y + dy),
                            scale(cubicBezierSegment.Point2.X + dx),
                            scale(cubicBezierSegment.Point2.Y + dy),
                            scale(cubicBezierSegment.Point3.X + dx),
                            scale(cubicBezierSegment.Point3.Y + dy));

                        previous = cubicBezierSegment.Point3;
                    }
                    else if (segment is XLineSegment)
                    {
                        var lineSegment = segment as XLineSegment;
                        path.LineTo(
                            scale(lineSegment.Point.X + dx),
                            scale(lineSegment.Point.Y + dy));

                        previous = lineSegment.Point;
                    }
                    else if (segment is XPolyCubicBezierSegment)
                    {
                        var polyCubicBezierSegment = segment as XPolyCubicBezierSegment;
                        if (polyCubicBezierSegment.Points.Length >= 3)
                        {
                            path.CubicTo(
                                scale(polyCubicBezierSegment.Points[0].X + dx),
                                scale(polyCubicBezierSegment.Points[0].Y + dy),
                                scale(polyCubicBezierSegment.Points[1].X + dx),
                                scale(polyCubicBezierSegment.Points[1].Y + dy),
                                scale(polyCubicBezierSegment.Points[2].X + dx),
                                scale(polyCubicBezierSegment.Points[2].Y + dy));

                            previous = polyCubicBezierSegment.Points[2];
                        }

                        if (polyCubicBezierSegment.Points.Length > 3
                            && polyCubicBezierSegment.Points.Length % 3 == 0)
                        {
                            for (int i = 3; i < polyCubicBezierSegment.Points.Length; i += 3)
                            {
                                path.CubicTo(
                                    scale(polyCubicBezierSegment.Points[i].X + dx),
                                    scale(polyCubicBezierSegment.Points[i].Y + dy),
                                    scale(polyCubicBezierSegment.Points[i + 1].X + dx),
                                    scale(polyCubicBezierSegment.Points[i + 1].Y + dy),
                                    scale(polyCubicBezierSegment.Points[i + 2].X + dx),
                                    scale(polyCubicBezierSegment.Points[i + 2].Y + dy));

                                previous = polyCubicBezierSegment.Points[i + 2];
                            }
                        }
                    }
                    else if (segment is XPolyLineSegment)
                    {
                        var polyLineSegment = segment as XPolyLineSegment;
                        if (polyLineSegment.Points.Length >= 1)
                        {
                            path.LineTo(
                                scale(polyLineSegment.Points[0].X + dx),
                                scale(polyLineSegment.Points[0].Y + dy));

                            previous = polyLineSegment.Points[0];
                        }

                        if (polyLineSegment.Points.Length > 1)
                        {
                            for (int i = 1; i < polyLineSegment.Points.Length; i++)
                            {
                                path.LineTo(
                                    scale(polyLineSegment.Points[i].X + dx),
                                    scale(polyLineSegment.Points[i].Y + dy));

                                previous = polyLineSegment.Points[i];
                            }
                        }
                    }
                    else if (segment is XPolyQuadraticBezierSegment)
                    {
                        var polyQuadraticSegment = segment as XPolyQuadraticBezierSegment;
                        if (polyQuadraticSegment.Points.Length >= 2)
                        {
                            path.QuadTo(
                                scale(polyQuadraticSegment.Points[0].X + dx),
                                scale(polyQuadraticSegment.Points[0].Y + dy),
                                scale(polyQuadraticSegment.Points[1].X + dx),
                                scale(polyQuadraticSegment.Points[1].Y + dy));

                            previous = polyQuadraticSegment.Points[1];
                        }

                        if (polyQuadraticSegment.Points.Length > 2
                            && polyQuadraticSegment.Points.Length % 2 == 0)
                        {
                            for (int i = 3; i < polyQuadraticSegment.Points.Length; i += 3)
                            {
                                path.QuadTo(
                                    scale(polyQuadraticSegment.Points[i].X + dx),
                                    scale(polyQuadraticSegment.Points[i].Y + dy),
                                    scale(polyQuadraticSegment.Points[i + 1].X + dx),
                                    scale(polyQuadraticSegment.Points[i + 1].Y + dy));

                                previous = polyQuadraticSegment.Points[i + 1];
                            }
                        }
                    }
                    else if (segment is XQuadraticBezierSegment)
                    {
                        var quadraticBezierSegment = segment as XQuadraticBezierSegment;
                        path.QuadTo(
                            scale(quadraticBezierSegment.Point1.X + dx),
                            scale(quadraticBezierSegment.Point1.Y + dy),
                            scale(quadraticBezierSegment.Point2.X + dx),
                            scale(quadraticBezierSegment.Point2.Y + dy));

                        previous = quadraticBezierSegment.Point2;
                    }
                    else
                    {
                        throw new NotSupportedException("Not supported segment type: " + segment.GetType());
                    }
                }

                if (xpf.IsClosed)
                {
                    path.Close();
                }
            }

            return path;
        }
 static SkiaSharp.SKPath CreatePolygon(PixelFarm.Drawing.PointF[] points)
 {
     SkiaSharp.SKPath p = new SkiaSharp.SKPath();
     int j = points.Length;
     PixelFarm.Drawing.PointF p0 = new PixelFarm.Drawing.PointF();
     for (int i = 0; i < j; ++i)
     {
         if (i == 0)
         {
             p0 = points[0];
             p.MoveTo(p0.X, p0.Y);
         }
         else if (i == j - 1)
         {
             //last one
             var point = points[i];
             p.LineTo(point.X, point.Y);
             p.LineTo(p0.X, p0.Y);
             p.Close();
             break;
         }
         else
         {
             var point = points[i];
             p.LineTo(point.X, point.Y);
         }
     }
     return p;
 }
        static SkiaSharp.SKPath ResolveGraphicsPath(GraphicsPath path)
        {
            //convert from graphics path to internal presentation
            SkiaSharp.SKPath innerPath = path.InnerPath as SkiaSharp.SKPath;
            if (innerPath != null)
            {
                return innerPath;
            }
            //--------
            innerPath = new SkiaSharp.SKPath();
            path.InnerPath = innerPath;
            List<float> points;
            List<PathCommand> cmds;
            GraphicsPath.GetPathData(path, out points, out cmds);
            int j = cmds.Count;
            int p_index = 0;
            for (int i = 0; i < j; ++i)
            {
                PathCommand cmd = cmds[i];
                switch (cmd)
                {
                    default:
                        throw new NotSupportedException();
                    case PathCommand.Arc:

                        var oval = SkiaSharp.SKRect.Create(points[p_index],
                            points[p_index + 1],
                            points[p_index + 2],
                            points[p_index + 3]);

                        innerPath.ArcTo(oval,
                            points[p_index + 4],
                            points[p_index + 5],
                            true);
                        p_index += 6;
                        break;
                    case PathCommand.Bezier:
                        innerPath.MoveTo(points[p_index]
                            , points[p_index + 1]);
                        innerPath.CubicTo(
                            points[p_index + 2],
                            points[p_index + 3],
                            points[p_index + 4],
                            points[p_index + 5],
                            points[p_index + 6],
                            points[p_index + 7]);
                        p_index += 8;
                        break;
                    case PathCommand.CloseFigure:
                        //?
                        break;
                    case PathCommand.Ellipse:

                        innerPath.AddOval(
                            SkiaSharp.SKRect.Create(
                                points[p_index],
                            points[p_index + 1],
                            points[p_index + 2],
                            points[p_index + 3]
                                ));

                        p_index += 4;
                        break;
                    case PathCommand.Line:

                        innerPath.MoveTo(points[p_index],
                            points[p_index + 1]);
                        innerPath.LineTo(
                            points[p_index + 2],
                            points[p_index + 3]);
                        p_index += 4;
                        break;
                    case PathCommand.Rect:
                        innerPath.AddRect(
                            SkiaSharp.SKRect.Create(
                                points[p_index],
                            points[p_index + 1],
                            points[p_index + 2],
                            points[p_index + 3]
                                ));
                        p_index += 4;
                        break;
                    case PathCommand.StartFigure:
                        break;
                }
            }


            return innerPath;
        }