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

SVGLoader: fix round rects when only rx or ry is specified #22124

Merged
merged 1 commit into from
Jul 13, 2021

Conversation

nkrkv
Copy link
Contributor

@nkrkv nkrkv commented Jul 13, 2021

The current implementation handles rect rounded corners incorrectly when either rx or ry attr is omitted.

Here’s a SVG made in Inkscape where only rx is specified:

image

round-rect.svg.zip

    <rect
       style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:square;stroke-linejoin:round"
       id="rect846"
       width="161.13248"
       height="78.283867"
       x="20.170506"
       y="27.046577"
       rx="10" />

Here’s how a browser renders it:

image

Here’s how THREE.js loads it without the fix:

image

And here’s how THREE.js loads it with the fix:

image


Indeed, the standard says:

When the computed value of ‘rx’ is auto, the used radius is equal to the absolute length used for ry, creating a circular arc.

The same applies to ry

@mrdoob mrdoob added this to the r131 milestone Jul 13, 2021
@mrdoob mrdoob merged commit 6530183 into mrdoob:dev Jul 13, 2021
@mrdoob
Copy link
Owner

mrdoob commented Jul 13, 2021

Thanks!

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