question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Weird artifacts with arcs in some paths

See original GitHub issue

Hi, I’ve run into an issue, where an arc segment seems to go missing when I convert a parsed path back to a string with d(). Here’s a visual example of what is happening:

image The left side is the original path and the right side is what I got by running the path through parse_path("...").d(). It looks like an arc segment is just left out.

To understand better what’s going on, here are the paths that create the two hearts above:

<!-- Original -->
<path
	d="
	m 1672.2372,-54.8161
	a 14.5445,14.5445 0 0 0 -11.3152,23.6652
	l 27.2573,27.2572 27.2572,-27.2572
	a 14.5445,14.5445 0 0 0 -11.3012,-23.634
	a 14.5445,14.5445 0 0 0 -11.414,5.4625
	l -4.542,4.5420
	l -4.5437,-4.5420
	a 14.5445,14.5445 0 0 0 -11.3984,-5.4937
	z"
	fill="none" stroke="#FF423F" stroke-width="2" stroke-linecap="square"
/>
<!-- Parsed -->
<path
	d="
	M 1772.24,-54.8161
	A 14.5445,14.5445 0 0,0 1760.92,-31.1509
	L 1788.18,-3.8937 L 1815.44,-31.1509
	A 14.5445,14.5445 0 0,0 1804.14,-54.7849
	A 14.5445,14.5445 0 0,0 1792.72,-49.3224
	L 1788.18,-44.7804
	L 1783.64,-49.3224
	Z"
	fill="none" stroke="#FF423F" stroke-width="2" stroke-linecap="square"
/>

The final arc before Z is clearly missing for some reason.

Also here’s what I ran on the python prompt to get the result above:

>>> p = parse_path("m 1772.2372,-54.8161 a 14.5445,14.5445 0 0 0 -11.3152,23.6652 l 27.2573,27.2572 27.2572,-27.2572 a 14.5445,14.5445 0 0 0 -11.3012,-23.634 14.5445,14.5445 0 0 0 -11.414,5.4625 l -4.542,4.5420 -4.5437,-4.5420 a 14.5445,14.5445 0 0 0 -11.3984,-5.4937 z")
>>> p
Path(Move(to=(1772.2372-54.8161j)), Arc(start=(1772.2372-54.8161j), radius=(14.5445+14.5445j), rotation=0.0, arc=False, sweep=False, end=(1760.922-31.1509j)), Line(start=(1760.922-31.1509j), end=(1788.1793-3.893699999999999j)), Line(start=(1788.1793-3.893699999999999j), end=(1815.4365-31.1509j)), Arc(start=(1815.4365-31.1509j), radius=(14.5445+14.5445j), rotation=0.0, arc=False, sweep=False, end=(1804.1353-54.7849j)), Arc(start=(1804.1353-54.7849j), radius=(14.5445+14.5445j), rotation=0.0, arc=False, sweep=False, end=(1792.7213-49.3224j)), Line(start=(1792.7213-49.3224j), end=(1788.1793-44.7804j)), Line(start=(1788.1793-44.7804j), end=(1783.6356-49.3224j)), Arc(start=(1783.6356-49.3224j), radius=(14.5445+14.5445j), rotation=0.0, arc=False, sweep=False, end=(1772.2372-54.8161j)), closed=True)
>>> p.d()
'M 1772.24,-54.8161 A 14.5445,14.5445 0 0,0 1760.92,-31.1509 L 1788.18,-3.8937 L 1815.44,-31.1509 A 14.5445,14.5445 0 0,0 1804.14,-54.7849 A 14.5445,14.5445 0 0,0 1792.72,-49.3224 L 1788.18,-44.7804 L 1783.64,-49.3224 Z'

EDIT: I did some testing and it seems like this is what ommits the last arc: https://github.com/regebro/svg.path/blob/master/src/svg/path/path.py#L434

Not sure what a real fix should be like, but I can probably work around it at least in some cases, by just doing p.closed = False before p.d().

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
richrdcommented, Apr 29, 2019

Yes that works, I mentioned it at the end of the issue 😃

0reactions
richrdcommented, Oct 31, 2019

Great, I’ll try to report back when I get round to testing this. Thank you! 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Weird artifact... light leak? - Beginning Deep Sky Imaging
The two arcs could be from a small light leak causing a reflection inside the telescope or image train. These can be very...
Read more >
Illustrator strange artifacts on curves
Try these first: ... Select the path and uncheck Align to Pixel Grid on the Transform Panel -- Solved. Apparently it's some sort...
Read more >
Firefox Canvas - Artifacts in path drawing (possible clipping ...
I wrote a Canvas program using some "advanced" graphics features: ... But in FireFox, it is possible to make an odd artifact appear:...
Read more >
Doctor Strange's 15 Best and Weirdest Artifacts - Screen Rant
Doctor Strange has amassed a lot of magical toys over the years. Here are the 15 best and most bizarre.
Read more >
Weird visual artifacts on mac os catalina, any fix? - Reddit
I'm running macOS Catalina 10.15.7 on a 16"MBP. Any ideas on how to fix this? Thanks!
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found