//--------------------------------------------------- public override void FillPath(Color color, GraphicsPath path) { //solid color var innerPath2 = path.InnerPath2; if (innerPath2 == null) { System.Drawing.Drawing2D.PathData pathData = path.GetPathData() as System.Drawing.Drawing2D.PathData; PixelFarm.Agg.VertexStore vxs = new PixelFarm.Agg.VertexStore(); PixelFarm.Agg.GdiPathConverter.ConvertToVxs(pathData, vxs); //TODO: reuse flattener PixelFarm.Agg.VertexSource.CurveFlattener flattener = new PixelFarm.Agg.VertexSource.CurveFlattener(); vxs = flattener.MakeVxs2(vxs); path.InnerPath2 = vxs; this.canvasGL2d.FillVxs(color, vxs); } else { PixelFarm.Agg.VertexStore vxs = innerPath2 as PixelFarm.Agg.VertexStore; if (vxs != null) { this.canvasGL2d.FillVxs(color, vxs); } } }
public override void FillPath(Brush brush, GraphicsPath path) { switch (brush.BrushKind) { case BrushKind.Solid: { SolidBrush solidBrush = (SolidBrush)brush; var innerPath2 = path.InnerPath2; if (innerPath2 == null) { System.Drawing.Drawing2D.PathData pathData = path.GetPathData() as System.Drawing.Drawing2D.PathData; PixelFarm.Agg.VertexStore vxs = new PixelFarm.Agg.VertexStore(); PixelFarm.Agg.GdiPathConverter.ConvertToVxs(pathData, vxs); //TODO: reuse flattener vxs = flattener.MakeVxs2(vxs); path.InnerPath2 = vxs; this.canvasGL2d.FillVxs(solidBrush.Color, vxs); } else { PixelFarm.Agg.VertexStore vxs = innerPath2 as PixelFarm.Agg.VertexStore; if (vxs != null) { this.canvasGL2d.FillVxs(solidBrush.Color, vxs); } } } break; case BrushKind.LinearGradient: { } break; default: { } break; } }
public override void DrawPath(GraphicsPath gfxPath) { var innerPath2 = gfxPath.InnerPath2; if (innerPath2 == null) { System.Drawing.Drawing2D.PathData pathData = gfxPath.GetPathData() as System.Drawing.Drawing2D.PathData; PixelFarm.Agg.VertexStore vxs = new PixelFarm.Agg.VertexStore(); PixelFarm.Agg.GdiPathConverter.ConvertToVxs(pathData, vxs); PixelFarm.Agg.VertexSource.CurveFlattener flattener = new PixelFarm.Agg.VertexSource.CurveFlattener(); vxs = flattener.MakeVxs2(vxs); gfxPath.InnerPath2 = vxs; this.canvasGL2d.DrawVxs(vxs); } else { PixelFarm.Agg.VertexStore vxs = innerPath2 as PixelFarm.Agg.VertexStore; if (vxs != null) { this.canvasGL2d.DrawVxs(vxs); } } }
static System.Drawing.Drawing2D.GraphicsPath ResolveGraphicsPath(GraphicsPath path) { //convert from graphics path to internal presentation System.Drawing.Drawing2D.GraphicsPath innerPath = path.InnerPath as System.Drawing.Drawing2D.GraphicsPath; if (innerPath != null) { return(innerPath); } //-------- innerPath = new System.Drawing.Drawing2D.GraphicsPath(); 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: innerPath.AddArc( points[p_index], points[p_index + 1], points[p_index + 2], points[p_index + 3], points[p_index + 4], points[p_index + 5]); p_index += 6; break; case PathCommand.Bezier: innerPath.AddBezier( points[p_index], points[p_index + 1], 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: innerPath.CloseFigure(); break; case PathCommand.Ellipse: innerPath.AddEllipse( points[p_index], points[p_index + 1], points[p_index + 2], points[p_index + 3]); p_index += 4; break; case PathCommand.Line: innerPath.AddLine( points[p_index], points[p_index + 1], points[p_index + 2], points[p_index + 3]); p_index += 4; break; case PathCommand.Rect: innerPath.AddRectangle( new System.Drawing.RectangleF( 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); }