rough-stuff / rough

Create graphics with a hand-drawn, sketchy, appearance
http://roughjs.com
MIT License
19.83k stars 613 forks source link

Path has been break apart when applying roughness = 2 #162

Open haan123 opened 4 years ago

haan123 commented 4 years ago

I have a path like this: https://jsfiddle.net/qetypnac/2/

image

I don't know this is a bug a not, but is there any work around to reduce the breaking parts of eclipse?

Thanks!

pshihn commented 4 years ago

The path you're drawing is not drawing a circle but a series of arcs. Those arcs get more exaggerated with higher roughness. You can update your path string to have a single arc

haan123 commented 4 years ago

Hi @pshihn,

That's an approach, but is there an API from roughjs to convert an eclipse shape to single arc path? Because the eclipse in the above shape was generated from roughjs generator.ellipse then it was used to do subtract boolean operation with the rectangle shape:

const rectangle = generator.rectangle(...);
const path1 =  generator.toPaths(rectangle);
const ellipse = generator.ellipse(...);
const path2 = generator.toPaths(ellipse);

subtract(path1, path2);

Thank you!