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

feat(convertShapeToPath): Optionally convert rects with rounded corners to paths #1963

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

baarde
Copy link

@baarde baarde commented Feb 13, 2024

Currently, rectangles with rounded corners are excluded from the convertShapeToPath optimization.

This PR adds the conversion of rectangles with rounded corners to paths when the convertArcs option is enabled.

Though the converted <path> is quite longer than the source <rect>, the conversion is still useful to people who wish to merge all the shapes into a single path.

@baarde
Copy link
Author

baarde commented Feb 13, 2024

Special cases

  • rx is absent → ry is used instead.
  • ry is absent → rx is used instead.
  • rx or ry is equal to zero → The <rect> is converted without rounded corners.
  • rx or ry is negative or not a number → The <rect> is not converted.
  • The computed value of rx is greater than half the widthrx is clamped to half the width.
  • The computed value of ry is greater than half the heightry is clamped to half the height.

@baarde
Copy link
Author

baarde commented Feb 13, 2024

I've just found out there's already a similar PR (#1816), which I totally missed. Sorry for the dupe. 😅

@baarde baarde changed the title Optionally convert rects with rounded corners to paths feat(convertShapeToPath): Optionally convert rects with rounded corners to paths Feb 13, 2024
baarde added a commit to baarde/lucide that referenced this pull request May 3, 2024
Add a custom plugin to convert rectangles with rounded corners to paths. Hopefully, this may be removed when svg/svgo#1963 or another similar PR is merged in SVGO.
baarde added a commit to baarde/lucide that referenced this pull request May 22, 2024
Add a custom plugin to convert rectangles with rounded corners to paths. Hopefully, this may be removed when svg/svgo#1963 or another similar PR is merged in SVGO.
@GreLI
Copy link
Member

GreLI commented Jun 9, 2024

AFAIK, I wrote that plugin and excluded it just for the fact it makes paths longer than rects. Nothing to do with optimization.

@dr-itz
Copy link

dr-itz commented Jun 25, 2024

AFAIK, I wrote that plugin and excluded it just for the fact it makes paths longer than rects. Nothing to do with optimization.

while the path version is longer than the rect, it would be great to have this as an option (not as default). Because tools like fontello.com cannot handle anything other than plain path...

baarde added a commit to baarde/lucide that referenced this pull request Jul 8, 2024
Add a custom plugin to convert rectangles with rounded corners to paths. Hopefully, this may be removed when svg/svgo#1963 or another similar PR is merged in SVGO.
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.

3 participants