vydd / sketch

A Common Lisp framework for the creation of electronic art, visual design, game prototyping, game making, computer graphics, exploration of human-computer interaction, and more.
MIT License
1.39k stars 66 forks source link

Don't triangulate polygon if it's already a triangle. #123

Closed Kevinpgalligan closed 7 months ago

Kevinpgalligan commented 7 months ago

A workaround for the polygon bug, for the case where the user just wants to draw a triangle: https://github.com/vydd/sketch/issues/15

Instead of trying to triangulate, just pass the triangle coordinates directly to draw-shape.

Testing

I used this fix to get one of my sketches working, see: https://github.com/Kevinpgalligan/sketches/blob/master/src/thesketches/snow.lisp#L60-L61

Without this fix, that sketch crashes immediately.

Kevinpgalligan commented 7 months ago

We could consider adding a temporary note to the polygon API that coordinates should be rational if there are more than 3 vertices. Would avoid anyone falling victim to the bug.