public void DrawPolygon(SvgPolygon svgPolygon, bool ignoreDisplay) { if (!CanDraw(svgPolygon, ignoreDisplay)) { return; } _skCanvas.Save(); var skMatrix = SkiaUtil.GetSKMatrix(svgPolygon.Transforms); SetTransform(skMatrix); SetClipPath(svgPolygon, _disposable); var skPaintOpacity = SetOpacity(svgPolygon, _disposable); var skPaintFilter = SetFilter(svgPolygon, _disposable); var skPath = SkiaUtil.ToSKPath(svgPolygon.Points, svgPolygon.FillRule, true, _disposable); if (skPath != null && !skPath.IsEmpty) { var skBounds = skPath.Bounds; if (SkiaUtil.IsValidFill(svgPolygon)) { var skPaint = SkiaUtil.GetFillSKPaint(svgPolygon, _skSize, skBounds, _disposable); _skCanvas.DrawPath(skPath, skPaint); } if (SkiaUtil.IsValidStroke(svgPolygon)) { var skPaint = SkiaUtil.GetStrokeSKPaint(svgPolygon, _skSize, skBounds, _disposable); _skCanvas.DrawPath(skPath, skPaint); } DrawMarkers(svgPolygon, skPath); } if (skPaintFilter != null) { _skCanvas.Restore(); } if (skPaintOpacity != null) { _skCanvas.Restore(); } _skCanvas.Restore(); }
void DrawGraph(SKCanvas canvas, SKPaint paint, DGraph2 graph, Func <Vector2d, SKPoint> mapF) { Colorf color = Colorf.Red; if (Colors.ContainsKey(graph)) { color = Colors[graph]; } paint.Color = SkiaUtil.Color(color); SKPath path = SkiaUtil.ToSKPath(graph, mapF); paint.StrokeWidth = 2; canvas.DrawPath(path, paint); paint.StrokeWidth = 1; //paint.Color = SKColors.Black; foreach (Vector2d v in graph.Vertices()) { SKPoint c = mapF(v); canvas.DrawCircle(c.X, c.Y, 3.0f, paint); } }
void DrawPolygon(SKCanvas canvas, SKPaint paint, GeneralPolygon2d poly, Func <Vector2d, SKPoint> mapF) { Colorf color = Colorf.Red; if (Colors.ContainsKey(poly)) { color = Colors[poly]; } paint.Color = SkiaUtil.Color(color); SKPath path = SkiaUtil.ToSKPath(poly, mapF); paint.StrokeWidth = 2; canvas.DrawPath(path, paint); //paint.Color = SKColors.Orange; paint.StrokeWidth = 1; foreach (Vector2d v in poly.AllVerticesItr()) { SKPoint c = mapF(v); canvas.DrawCircle(c.X, c.Y, 3.0f, paint); } }