CreativeInquiry / PEmbroider

Embroidery Library for Processing
Other
442 stars 28 forks source link

Errors rendering lines #19

Closed golanlevin closed 4 years ago

golanlevin commented 4 years ago

Hi @LingDong- , See the example, PEmbroider_lines_1. Issues include:

PEmbroider_lines_1
LingDong- commented 4 years ago

Hi @golanlevin

strokeCap currently does not work for PERPENDICULAR.

strokeCap works for TANGENT because TANGENT is rasterizing the line first using Processing's renderer which supports all the strokeCap and strokeJoins, and then tracing it out. PERPENDICULAR is using shaky vector math. Similarly strokeJoin also does not work for PERPENDICULAR. I can work on making these work for PERPENDICULAR too.

The end cap looks like a full circle because the logic behind it actually is like this: at all the corners, try to do a full circle, but throw away the ones that overlaps with existing strokes. This prevents error prone math when there are lots of different angles turning in all directions.

I think the main issue is a fencepost error, we need to draw n+1 strokes when divided into n intervals. The missing very last stroke is causing the circle to complete when the spacing is high.

LingDong- commented 4 years ago

Fixed circular ends, and invisible strokeWeight(2);

34fcd839f91105b809520ba0fdc7bcc01c9fa59b

Turns out strokeWeight(2) was invisible because the algorithm runs ceil(w)-1 steps, so for 2, it runs 1 steps, producing invisible polylines of length 1.

golanlevin commented 4 years ago

Thanks!!