Values of SvgPathSegment became relative (not absolute as earlier) when iterating through the SvgPathSegmentList
Description
Somewhere between versions 3.0.84 and 3.4.7 the default behaviour of iterating through SvgPathSegmentList changed.
In the 3.0.84 version iterating through the SvgPathSegmentList returns SvgPathSegment result as absolute coordinates of the point.
In the 3.4.7 version the object SvgPathSegment has relative coordinates with an additional property 'IsRelative' set to 'true'
Example data
<path d="M2639.9,1960.88l1.26,1.11l-0.36,1.79l-1.79,1.58 .....
Was the change intentional? I did not find any breaking changes in the release notes.
Is there a flag or a setting I can use to return the default behavior to absolute coordinates without the need to calculate them manually?
Thank you.
Workaround that I've currently implemented in my project:
PointF absolutePoint = new PointF(0, 0);
foreach (var point in path.PathData)
{
absolutePoint = ToAbsolute(point.End, point.IsRelative, absolutePoint);
... do what you need to do with the absolutePoint
}
Where ToAbsolute I took from the abstract class SvgPathSegment
protected static PointF ToAbsolute(PointF point, bool isRelative, PointF start)
{
if (float.IsNaN(point.X))
point.X = start.X;
else if (isRelative)
point.X += start.X;
if (float.IsNaN(point.Y))
point.Y = start.Y;
else if (isRelative)
point.Y += start.Y;
return point;
}
Was the change intentional? I did not find any breaking changes in the release notes.
Yes, see #925. And yes, the release notes for this are not really helpful in that respect.
Is there a flag or a setting I can use to return the default behavior to absolute coordinates without the need to calculate them manually?
Not that I know of, though @H1Gdev might know more.
@hubaksis
In the previous version, relative information was lost when read SVG into DOM.
(SVG(relative) -> SvgDocument(absolute) -> SVG(absolute))
We supported relatives with PR #925.
For conversion, I think you should use ToAbsolute logic. You can calculate each point in this method sequentially.