public static PolygonDrawable Create(SvgPolygon svgPolygon, SKRect skViewport, DrawableBase?parent, IAssetLoader assetLoader, HashSet <Uri>?references, DrawAttributes ignoreAttributes = DrawAttributes.None) { var drawable = new PolygonDrawable(assetLoader, references) { Element = svgPolygon, Parent = parent, IgnoreAttributes = ignoreAttributes }; drawable.IsDrawable = drawable.CanDraw(svgPolygon, drawable.IgnoreAttributes) && drawable.HasFeatures(svgPolygon, drawable.IgnoreAttributes); if (!drawable.IsDrawable) { return(drawable); } drawable.Path = svgPolygon.Points?.ToPath(svgPolygon.FillRule, true, skViewport); if (drawable.Path is null || drawable.Path.IsEmpty) { drawable.IsDrawable = false; return(drawable); } drawable.Initialize(skViewport, references); return(drawable); }
public static PolygonDrawable Create(SvgPolygon svgPolygon, Rect skOwnerBounds, DrawableBase?parent, IAssetLoader assetLoader, Attributes ignoreAttributes = Attributes.None) { var drawable = new PolygonDrawable(assetLoader) { Element = svgPolygon, Parent = parent, IgnoreAttributes = ignoreAttributes }; drawable.IsDrawable = drawable.CanDraw(svgPolygon, drawable.IgnoreAttributes) && drawable.HasFeatures(svgPolygon, drawable.IgnoreAttributes); if (!drawable.IsDrawable) { return(drawable); } drawable.Path = svgPolygon.Points?.ToPath(svgPolygon.FillRule, true, skOwnerBounds); if (drawable.Path is null || drawable.Path.IsEmpty) { drawable.IsDrawable = false; return(drawable); } drawable.IsAntialias = SvgModelExtensions.IsAntialias(svgPolygon); drawable.TransformedBounds = drawable.Path.Bounds; drawable.Transform = SvgModelExtensions.ToMatrix(svgPolygon.Transforms); var canDrawFill = true; var canDrawStroke = true; if (SvgModelExtensions.IsValidFill(svgPolygon)) { drawable.Fill = SvgModelExtensions.GetFillPaint(svgPolygon, drawable.TransformedBounds, assetLoader, ignoreAttributes); if (drawable.Fill is null) { canDrawFill = false; } } if (SvgModelExtensions.IsValidStroke(svgPolygon, drawable.TransformedBounds)) { drawable.Stroke = SvgModelExtensions.GetStrokePaint(svgPolygon, drawable.TransformedBounds, assetLoader, ignoreAttributes); if (drawable.Stroke is null) { canDrawStroke = false; } } if (canDrawFill && !canDrawStroke) { drawable.IsDrawable = false; return(drawable); } SvgModelExtensions.CreateMarkers(svgPolygon, drawable.Path, skOwnerBounds, drawable, assetLoader); // TODO: Transform _skBounds using _skMatrix. drawable.TransformedBounds = drawable.Transform.MapRect(drawable.TransformedBounds); return(drawable); }