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

[convertPath]: combine arcs and convert full arcs to circles #1748

Open
jguddas opened this issue Feb 15, 2023 · 4 comments
Open

[convertPath]: combine arcs and convert full arcs to circles #1748

jguddas opened this issue Feb 15, 2023 · 4 comments

Comments

@jguddas
Copy link

jguddas commented Feb 15, 2023

Is your feature request related to a problem? Please describe.
There is already logic that merges curves into arcs, but it only works with curves and not a mix of curves and arcs.

Describe the solution you'd like

  1. Convert all arcs with rx == ry to curves before running the curve merge logic
  2. Convert all curves to arcs and replace the curve merge logic with an arc merge variant.

Additional context
Also, 2 half circles could be converted to a circle element.
This could use the same logic, but might be better placed in a separate plugin.

- <path d="M8 10a2 2 0 1 0 0-4 2 2 0 0 0 0 4Z"/>
+ <circle cx="8" cy="8" r="2"/>
@jguddas jguddas changed the title [convertPath]: convert path segments to arcs [convertPath]: convert path segments to arcs and arcs to circles Feb 17, 2023
@jguddas jguddas changed the title [convertPath]: convert path segments to arcs and arcs to circles [convertPath]: convert path segments to arcs, combine arcs and convert full arcs to circles Feb 17, 2023
@jguddas jguddas changed the title [convertPath]: convert path segments to arcs, combine arcs and convert full arcs to circles [convertPath]: combine arcs and convert full arcs to circles Feb 17, 2023
jguddas added a commit to jguddas/svgo that referenced this issue Feb 27, 2023
jguddas added a commit to jguddas/svgo that referenced this issue Feb 27, 2023
@jguddas
Copy link
Author

jguddas commented Nov 12, 2023

@SethFalco I have a working version here, code is not in the shape svgo expects and a bit of a mess tho.

Example: https://lucide-site-git-feat-added-edit-page-jguddas.vercel.app/edit

@KTibow
Copy link
Contributor

KTibow commented Nov 12, 2023

Is this intended?
image
gets optimized to
image

@jguddas
Copy link
Author

jguddas commented Nov 12, 2023

@KTibow Looks like you found a bug, did a quick test, that bug only exists in the deployed version.

I haven't had the time to clean things up and deploy the newest version, I can reproduce it on the hosted version but locally (with the code in the branch that I have linked) it works.

@GreLI
Copy link
Member

GreLI commented Jun 9, 2024

There is a trick to do circles with one arc instead of two arcs by making a tiny step like 0.01 pixel. It makes even shorter paths than circle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants