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); }
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; }