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

Should empty arc be dropped ? #20

Closed
kpym opened this issue Dec 31, 2015 · 6 comments
Closed

Should empty arc be dropped ? #20

kpym opened this issue Dec 31, 2015 · 6 comments
Labels

Comments

@kpym
Copy link
Contributor

kpym commented Dec 31, 2015

I know that you follow the W3C where we can read "If the endpoints (x1, y1) and (x2, y2) are identical, then this is equivalent to omitting the elliptical arc segment entirely.".
But this is dangerous because the browsers don't do this. Check the following paths

  • "M 0 0 C 0 10 10 10 10 0 A 10 10 0 0 0 10 0 S 20 -10 20 0" (with empty arc segment)
  • "M 0 0 C 0 10 10 10 10 0 S 20 -10 20 0" (with empty arc segment removed)
  • "M 0 0 C 0 10 10 10 10 0 L 10 0 S 20 -10 20 0" (with empty line segment)

You can see that the browser treats the empty arc like empty line segment, and don't drop it.
The only situation where dropping arc is dangerous is before short commands (S, s, T,t).

By the way this 'drop empty arcs' rule is inconsistent with the other type of segments. Why to drop empty arcs and not to drop empty lines ?

@puzrin
Copy link
Member

puzrin commented Dec 31, 2015

What do you suggest?

@kpym
Copy link
Contributor Author

kpym commented Dec 31, 2015

Two options :

  • simpler : always simplify empty arc to empty line (but don't drop it).
  • more complicated : remove empty arcs only if they are not followed by S,s,T or t, else drop them.

In the case of the more complicated choice it could be applied to all empty segments, except M and m.
This is what I do in my repo (see the .normalize() method).

@puzrin
Copy link
Member

puzrin commented Dec 31, 2015

Could you explain how S/s/T/t are affected by previous arc?

PS. replace with L/l looks ok for me. We removed arc only because of spec, svgpath is not expected to optimize anything, that's not svgo.

@kpym
Copy link
Contributor Author

kpym commented Dec 31, 2015

As you can see in my example if we have "C X S" sequence (with X not C or S, for example =A) the S first control point is considered as the starting point. But if we drop X (=A in our case), in the sequence "C S" the first control point of S is taken from C.

@puzrin
Copy link
Member

puzrin commented Dec 31, 2015

Ah! Got it, thanks!

@kpym
Copy link
Contributor Author

kpym commented Dec 31, 2015

I came to ask the question on stackoverflow.

@puzrin puzrin added the bug label Jan 2, 2016
puzrin pushed a commit that referenced this issue Jan 3, 2016
@puzrin puzrin closed this as completed Jan 3, 2016
puzrin pushed a commit that referenced this issue Jan 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants