From f21eebf029e27967587180853ae22d978502cfe1 Mon Sep 17 00:00:00 2001 From: H1Gdev Date: Sun, 4 Aug 2019 19:18:51 +0900 Subject: [PATCH] Small refactoring for Transforms. --- Source/Filter Effects/SvgFilter.cs | 7 +++---- Source/SvgElement.cs | 2 -- Source/Text/SvgTextPath.cs | 8 ++------ 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/Source/Filter Effects/SvgFilter.cs b/Source/Filter Effects/SvgFilter.cs index b73d17341..277f31fe9 100644 --- a/Source/Filter Effects/SvgFilter.cs +++ b/Source/Filter Effects/SvgFilter.cs @@ -78,10 +78,9 @@ protected override void Render(ISvgRenderer renderer) private Matrix GetTransform(SvgVisualElement element) { var transformMatrix = new Matrix(); - foreach (var transformation in element.Transforms) - { - transformMatrix.Multiply(transformation.Matrix); - } + if (element.Transforms != null) + foreach (var transformation in element.Transforms) + transformMatrix.Multiply(transformation.Matrix); return transformMatrix; } diff --git a/Source/SvgElement.cs b/Source/SvgElement.cs index cae89047e..06b8d82a6 100644 --- a/Source/SvgElement.cs +++ b/Source/SvgElement.cs @@ -522,8 +522,6 @@ public SvgElement() this._elementName = string.Empty; this._customAttributes = new SvgCustomAttributeCollection(this); - Transforms = new SvgTransformCollection(); - //subscribe to attribute events Attributes.AttributeChanged += Attributes_AttributeChanged; CustomAttributes.AttributeChanged += Attributes_AttributeChanged; diff --git a/Source/Text/SvgTextPath.cs b/Source/Text/SvgTextPath.cs index 2a68b90db..569671474 100644 --- a/Source/Text/SvgTextPath.cs +++ b/Source/Text/SvgTextPath.cs @@ -60,15 +60,11 @@ protected override GraphicsPath GetBaselinePath(ISvgRenderer renderer) var path = this.OwnerDocument.IdManager.GetElementById(this.ReferencedPath) as SvgVisualElement; if (path == null) return null; var pathData = (GraphicsPath)path.Path(renderer).Clone(); - if (path.Transforms.Count > 0) + if (path.Transforms != null && path.Transforms.Count > 0) { - Matrix transformMatrix = new Matrix(1, 0, 0, 1, 0, 0); - + var transformMatrix = new Matrix(1, 0, 0, 1, 0, 0); foreach (var transformation in path.Transforms) - { transformMatrix.Multiply(transformation.Matrix); - } - pathData.Transform(transformMatrix); } return pathData;