-
-
Notifications
You must be signed in to change notification settings - Fork 29
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
Improve __repr__ and Viewbox #117
Conversation
1. Viewbox `init` now handles various forms of arguments so it can recreate from a repr: * "x y w h" * x=x etc. 2. Viewbox creates a correct better `repr`. 3. SVGImage adds missing attributes, puts the href (which is potentially huge) last and (I hope this is correct) puts the href attribute in quotations so that the end is easily parseable.
Since `**kwargs` are often converted using attribute name, we need to use `preserveAspectRatio` everywhere instead of `preserve_aspect_ratio`. We also need to convert "none" to `None`.
I believe this is ready for merging subject to review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perserve_aspect_ratio cannot be changed without preserving backwards compatibility
This is a serious breaking change that is completely unneeded to tweaking viewbox to init a couple other ways.
SVG_ATTR_PATTERN_CONTENT_UNITS = "patternContentUnits"
self.pattern_content_units = values[SVG_ATTR_PATTERN_CONTENT_UNITS]
SVG_ATTR_CLIP_UNIT_TYPE = "clipPathUnits"
self.unit_type = SVG_UNIT_TYPE_USERSPACEONUSE |
These are NOT part of the SVG 2.0 spec.
Apologies for breaking backward compatibility. Hopefully this is now OK. |
Ok - hopefully this should be backwards compatible and addresses all concerns (which have also had unit tests added for). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I'd prefer the snake case for the preserveAspectRatio it's pretty clear that that would also work. I think if I go into Issue 87 I'll actually opt to avoid all snake case and go pure SVG cases
I thought that conformance to svg was more important. It could potentially have been backwards incompatible, but:
Now you have brought my attention to there being other examples, I will put making similar "fixes" on my to-do list. 😉 But before you get too worried, getting to the top of the list seems unlikely. |
stroke-width is not handled properly. some attribute name are hard-coded in repr rather than referring to the attribute contant. but this is low priority so not aiming to address either of these any time soon. |
init
now handles various forms of arguments so it can recreate from a repr:repr
.preserve_aspect_ratio
as an attribute when the SVG attribute ispreserveAspectRatio
. Backwards compatibility is preserved.