-
-
Notifications
You must be signed in to change notification settings - Fork 117
Add pattern support & marker without viewBox attribute #369
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
Conversation
|
Pattern parsing is not complete but works for my use case, I'll look into a more complete version but will not be confident it works because I have not use case to validate against. BUT first let me know if you are interested in this ... |
svg.go
Outdated
| return Black | ||
| } | ||
| col.A = svg.parseColorComponent(comps[3]) | ||
| // Alpha can be decimal (0.0-1.0) or integer (0-255) |
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.
I don't think this is true, it should only support decimal values between 0.0 (full transparent) and 1.0 (full opaque). Maybe this was wrong before?
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.
Sorry I did not realize the previous code was just wrong and wanted to maintain compatibility by falling back to it... my bad, will fix!!
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.
Amended my commit to only support decimal and not fallback to old code!
| } | ||
|
|
||
| f := height / viewbox[3] | ||
| f := 1.0 |
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.
Is this the default value for the viewbox height? Not sure about this...
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.
When no viewBox, content uses marker coordinate space directly, which equates to scale 1.0
Would you like me to add a comment to explain the reasoning ?
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.
pushed an amended commit with the comment
svg.go
Outdated
| width = 8.0 | ||
| } | ||
| if height == 0.0 { | ||
| height = 8.0 |
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.
Are these the defaults?
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.
You are right in svg specs pattern width/height default to 0, and a pattern with 0 dimensions simply doesn't render...
Should I update my code to return early if dimensions are 0 ? something like:
if width == 0.0 || height == 0.0 {
return // Pattern with zero dimensions does not render
}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.
pushed an amended commit with this solution tell me we you think...
Prevent division by zero when parsing <marker> elements that don't specify a viewBox. Default scale factor to 1.0 when viewBox height is zero.
- Parse <pattern> elements containing line hatches - Convert to HatchPattern with angle from patternTransform - Add currentColor to SVG state for dynamic color resolution - Parse CSS color property in style attributes - Resolve currentColor at pattern application time
|
Thanks for the effort! |
Also add support for decimal alpha values in rgba()
Added tests for each feature too...