Skip to content
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

parse radialGradient radius as percentage of viewport diagonal, not width #222

Merged
merged 2 commits into from
May 20, 2021

Conversation

anthrotype
Copy link
Member

currently we do:

self.r = number_or_percentage(el.attrib.get("r", "50%"), width)

But the SVG spec says

For any other length value expressed as a percentage of the SVG viewport, the percentage must be calculated as a percentage of the normalized diagonal of the ‘viewBox’ applied to that viewport. If no ‘viewBox’ is specified, then the normalized diagonal of the SVG viewport must be used. The normalized diagonal length must be calculated with sqrt((width)**2 + (height)**2)/sqrt(2).

So we should do the right thing (even if percentages usually are used with objectBoundingBox where the unit square by definition is width==height==1).

I push the failing test first, then the fix

@anthrotype anthrotype requested a review from rsheeter May 19, 2021 18:16
@anthrotype anthrotype merged commit ef65249 into main May 20, 2021
@anthrotype anthrotype deleted the gradient-radius-percent-of-diagonal branch May 20, 2021 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants