Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
- fixes issues #273  and #274
  • Loading branch information
paulushub committed Dec 12, 2023
1 parent b6a62df commit 27b5998
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Samples/WpfW3cSvgTestSuite/Output/SvgTestResults11.xml
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,25 @@
<category label="Data Types" total="15" unknowns="0" failures="6" successes="6" partials="3" />
<category label="Metadata and Others" total="7" unknowns="0" failures="2" successes="3" partials="2" />
</result>
<result version="1.8.2.0" date="2023-12-13T01:00:24.8070483+09:00">
<category label="Animations" total="78" unknowns="0" failures="78" successes="0" partials="0" />
<category label="Colors" total="6" unknowns="0" failures="0" successes="5" partials="1" />
<category label="Coordinates and Transforms" total="32" unknowns="0" failures="4" successes="28" partials="0" />
<category label="Filter Effects" total="43" unknowns="0" failures="43" successes="0" partials="0" />
<category label="Fonts" total="17" unknowns="0" failures="0" successes="15" partials="2" />
<category label="Interactivities" total="24" unknowns="0" failures="24" successes="0" partials="0" />
<category label="Linking" total="12" unknowns="0" failures="12" successes="0" partials="0" />
<category label="Masking" total="19" unknowns="0" failures="6" successes="11" partials="2" />
<category label="Paint Servers" total="33" unknowns="0" failures="0" successes="33" partials="0" />
<category label="Painting" total="31" unknowns="0" failures="0" successes="28" partials="3" />
<category label="Paths" total="21" unknowns="0" failures="1" successes="18" partials="2" />
<category label="Rendering" total="8" unknowns="0" failures="0" successes="8" partials="0" />
<category label="Scripting" total="6" unknowns="0" failures="6" successes="0" partials="0" />
<category label="Shapes" total="22" unknowns="0" failures="0" successes="22" partials="0" />
<category label="Structures" total="72" unknowns="0" failures="27" successes="42" partials="3" />
<category label="Styling" total="18" unknowns="0" failures="2" successes="16" partials="0" />
<category label="Text" total="62" unknowns="0" failures="10" successes="33" partials="19" />
<category label="Data Types" total="15" unknowns="0" failures="6" successes="6" partials="3" />
<category label="Metadata and Others" total="7" unknowns="0" failures="2" successes="3" partials="2" />
</result>
</results>
1 change: 1 addition & 0 deletions Source/SharpVectorModel/BasicTypes/SvgLengthList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public void FromString(string listString)
// remove leading and trailing whitespace
// NOTE: Need to check if .NET whitespace = SVG (XML) whitespace
listString = listString.Trim();
listString = listString.Trim(',');

if (listString.Length > 0)
{
Expand Down
105 changes: 105 additions & 0 deletions Source/SharpVectorRenderingWpf/Utils/WpfConvert.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Media;

Expand Down Expand Up @@ -442,5 +443,109 @@ public static double GetPathFigureLength(PathFigure pathFigure)
return length;
}


public static Transform GetTransform(SvgElement svgElement, bool _combineTransforms = true)
{
ISvgTransformable transElm = svgElement as ISvgTransformable;
if (transElm == null)
{
return null;
}

Transform transformMatrix = null;

SvgTransformList transformList = (SvgTransformList)transElm.Transform.AnimVal;
if (transformList.NumberOfItems != 0 && _combineTransforms == false)
{
List<Transform> transforms = new List<Transform>();

for (uint i = 0; i < transformList.NumberOfItems; i++)
{
ISvgTransform transform = transformList.GetItem(i);
double[] values = transform.InputValues;
switch (transform.TransformType)
{
case SvgTransformType.Translate:
if (values.Length == 1)
{
transforms.Add(new TranslateTransform(values[0], 0));
}
else if (values.Length == 2)
{
transforms.Add(new TranslateTransform(values[0], values[1]));
}
break;
case SvgTransformType.Rotate:
if (values.Length == 1)
{
transforms.Add(new RotateTransform(values[0]));
}
else if (values.Length == 3)
{
transforms.Add(new RotateTransform(values[0], values[1], values[2]));
}
break;
case SvgTransformType.Scale:
if (values.Length == 1)
{
transforms.Add(new ScaleTransform(values[0], values[0]));
}
else if (values.Length == 2)
{
transforms.Add(new ScaleTransform(values[0], values[1]));
}
break;
case SvgTransformType.SkewX:
if (values.Length == 1)
{
transforms.Add(new SkewTransform(values[0], 0));
}
break;
case SvgTransformType.SkewY:
if (values.Length == 1)
{
transforms.Add(new SkewTransform(0, values[0]));
}
break;
case SvgTransformType.Matrix:
if (values.Length == 6)
{
transforms.Add(new MatrixTransform(values[0],
values[1], values[2], values[3], values[4], values[5]));
}
break;
}
}

if (transforms.Count == 1)
{
transformMatrix = transforms[0];

}
else if (transforms.Count > 1)
{
transforms.Reverse();

TransformGroup transformGroup = new TransformGroup();
transformGroup.Children = new TransformCollection(transforms);
transformMatrix = transformGroup;
}

return transformMatrix;
}
SvgMatrix svgMatrix = transformList.TotalMatrix;

if (svgMatrix.IsIdentity)
{
return transformMatrix;
}

transformMatrix = new MatrixTransform(Math.Round(svgMatrix.A, 6), Math.Round(svgMatrix.B, 6),
Math.Round(svgMatrix.C, 6), Math.Round(svgMatrix.D, 6),
Math.Round(svgMatrix.E, 6), Math.Round(svgMatrix.F, 6));

return transformMatrix;
}

}
}
6 changes: 6 additions & 0 deletions Source/SharpVectorRenderingWpf/Wpf/WpfRendering.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,12 @@ private GeometryCollection CreateClippingRegion(SvgClipPathElement clipPath,

if (childPath != null)
{
var clipTransform = WpfConvert.GetTransform(element, _combineTransforms);
if (clipTransform != null)
{
childPath.Transform = clipTransform;
}

geomColl.Add(childPath);
}
}
Expand Down

0 comments on commit 27b5998

Please sign in to comment.