private void Initialize(HashSet <Uri>?references) { if (Element is not SvgGroup svgGroup) { return;; } IsAntialias = SvgExtensions.IsAntialias(svgGroup); GeometryBounds = SKRect.Empty; CreateGeometryBounds(); Transform = SvgExtensions.ToMatrix(svgGroup.Transforms); if (SvgExtensions.IsValidFill(svgGroup)) { Fill = SvgExtensions.GetFillPaint(svgGroup, GeometryBounds, AssetLoader, references, IgnoreAttributes); } if (SvgExtensions.IsValidStroke(svgGroup, GeometryBounds)) { Stroke = SvgExtensions.GetStrokePaint(svgGroup, GeometryBounds, AssetLoader, references, IgnoreAttributes); } }
private void Initialize() { if (Element is not SvgAnchor svgAnchor) { return;; } IsAntialias = SvgExtensions.IsAntialias(svgAnchor); GeometryBounds = SKRect.Empty; CreateGeometryBounds(); Transform = SvgExtensions.ToMatrix(svgAnchor.Transforms); Fill = null; Stroke = null; ClipPath = null; MaskDrawable = null; Opacity = IgnoreAttributes.HasFlag(DrawAttributes.Opacity) ? null : SvgExtensions.GetOpacityPaint(svgAnchor); Filter = null; }
private void Initialize(SKRect skViewport, float x, float y, SKSize skSize) { if (Element is not SvgFragment svgFragment) { return;; } IsAntialias = SvgExtensions.IsAntialias(svgFragment); GeometryBounds = skViewport; CreateGeometryBounds(); Transform = SvgExtensions.ToMatrix(svgFragment.Transforms); var skViewBoxMatrix = SvgExtensions.ToMatrix(svgFragment.ViewBox, svgFragment.AspectRatio, x, y, skSize.Width, skSize.Height); Transform = Transform.PreConcat(skViewBoxMatrix); switch (svgFragment.Overflow) { case SvgOverflow.Auto: case SvgOverflow.Visible: case SvgOverflow.Inherit: break; default: if (skSize.IsEmpty) { Overflow = SKRect.Create( x, y, Math.Abs(GeometryBounds.Left) + GeometryBounds.Width, Math.Abs(GeometryBounds.Top) + GeometryBounds.Height); } else { Overflow = SKRect.Create(x, y, skSize.Width, skSize.Height); } break; } var clipPathUris = new HashSet <Uri>(); var svgClipPath = svgFragment.GetUriElementReference <SvgClipPath>("clip-path", clipPathUris); if (svgClipPath?.Children is { })
private void Initialize(SKRect skViewport, HashSet <Uri>?references) { if (Element is not SvgPath svgPath || Path is null) { return; } IsAntialias = SvgExtensions.IsAntialias(svgPath); GeometryBounds = Path.Bounds; Transform = SvgExtensions.ToMatrix(svgPath.Transforms); var canDrawFill = true; var canDrawStroke = true; if (SvgExtensions.IsValidFill(svgPath)) { Fill = SvgExtensions.GetFillPaint(svgPath, GeometryBounds, AssetLoader, references, IgnoreAttributes); if (Fill is null) { canDrawFill = false; } } if (SvgExtensions.IsValidStroke(svgPath, GeometryBounds)) { Stroke = SvgExtensions.GetStrokePaint(svgPath, GeometryBounds, AssetLoader, references, IgnoreAttributes); if (Stroke is null) { canDrawStroke = false; } } if (canDrawFill && !canDrawStroke) { IsDrawable = false; return; } SvgExtensions.CreateMarkers(svgPath, Path, skViewport, this, AssetLoader, references); }
private void Initialize(float x, float y, float width, float height) { if (Element is not SvgSymbol svgSymbol) { return; } IsAntialias = SvgExtensions.IsAntialias(svgSymbol); GeometryBounds = SKRect.Empty; CreateGeometryBounds(); Transform = SvgExtensions.ToMatrix(svgSymbol.Transforms); var skMatrixViewBox = SvgExtensions.ToMatrix(svgSymbol.ViewBox, svgSymbol.AspectRatio, x, y, width, height); Transform = Transform.PreConcat(skMatrixViewBox); Fill = null; Stroke = null; }
private void Initialize(HashSet <Uri>?references) { if (Element is not SvgCircle svgCircle || Path is null) { return;; } IsAntialias = SvgExtensions.IsAntialias(svgCircle); GeometryBounds = Path.Bounds; Transform = SvgExtensions.ToMatrix(svgCircle.Transforms); var canDrawFill = true; var canDrawStroke = true; if (SvgExtensions.IsValidFill(svgCircle)) { Fill = SvgExtensions.GetFillPaint(svgCircle, GeometryBounds, AssetLoader, references, IgnoreAttributes); if (Fill is null) { canDrawFill = false; } } if (SvgExtensions.IsValidStroke(svgCircle, GeometryBounds)) { Stroke = SvgExtensions.GetStrokePaint(svgCircle, GeometryBounds, AssetLoader, references, IgnoreAttributes); if (Stroke is null) { canDrawStroke = false; } } if (canDrawFill && !canDrawStroke) { IsDrawable = false; } }