-
-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong transform is added for SVG with viewbox origin != (0,0) #236
Comments
Tested. This is accurate. The problem isn't that the transform is added, the transform is technically valid, it's that if we're writing a viewbox we actually generate a counter-transform by doing that even if the viewbox is technically identical to the one we started with. |
This is actually because the export write done in #228 doesn't account for the fact that the viewbox will technically cause a transform and that transform should actually be inverted and applied to the shapes via the viewbox-to-transform algorithm. Basically what happened is that the when we parsed we got rid of the viewbox by turning it into a transform. We applied that to all of the geometric shapes. Then we just sort of write the viewbox back to the design without taking into account that any viewbox would technically actually cause our shapes to invert. We either need to counter-transform all the shapes or we need to modify the viewbox between loading and saving. When you have a viewbox, the parsing actually scales our geometric objects up to make that viewbox equal to effectively an identity matrix. On the write, we apply the viewbox again, but we didn't reverse the effects on all the geometric objects when we did that. Also, we may actually want to change our viewbox and we should probably account for that. I'm unsure whether this might better fall into the The viewbox is just where you're viewing the objects. When loaded the viewbox was applied to the geometric data since this is sort of expected. But, technically the viewbox doesn't scale up the geometry it just makes it look bigger because your view is smaller. So if our viewbox is really 1mm x 1mm and we're using it to view a circle located at 15mm, 15mm with a 1mm diameter giving us a viewbox of In a very real sense we deleted the viewbox and should have no viewbox or we should make a viewbox that is always located at (0,0) and is the size of our design (so it produces an identity matrix). |
When reading and writing an SVG with viewbox not starting at (0,0), a wrong transform is added:
Input:
Output:
Expected:
I suppose this is because the original
x
andy
attribute is just written-as is, because the decimal point is missing and querying thex
position of the parsedRect
, it correctly returns0.0
. The transform is then probably added to move the rect back to (10, 10), ignoring the fact that theRect
is already placed at (10, 10) withx
andy
.This issue may also apply to other shapes.
The text was updated successfully, but these errors were encountered: