3 ms·
SVG Jigsaw Generation in Clojure
- alanbernstein 7y agoWhen working on a jigsaw generation project a few years ago, I was surprised to find basically no resources describing the process of procedurally generating the "nubs". There isn't much to it, I suppose, but I had to tinker with my implementation for a bit before I got it looking (mostly) right. The nubs in the second example here are similarly just a little bit different than what you'd see on a brand-name puzzle. Definitely looking forward to checking out the clojure code for this. Results here: https://github.com/alanbernstein/pyzzle https://github.com/alanbernstein/pyzzle. I guess I could write up a blog post with some diagrams on how that generation works, but there are so many TODO items in the code I'd rather work on first...
- taejo 7y agoWhen I did this I just drew a bunch of different puzzle-piece edges, making sure that they all had corresponding Bezier control points (easiest way to do this is to draw one and then move the points around in the copies without adding or changing the types of any points), and then treated then generated linear combinations of these. Did you have a different way? My goal was to cut a puzzle with two different solutions. It worked, but it turns out that a puzzle with two different solutions has many, many partial solutions (especially if you can't distinguish front from back!) and it's pretty frustrating!
- alanbernstein 7y agoI drew one archetypal shape, then add random noise to the spline control points for each instance. That means, to get the results looking right, I had to tweak the archetype, and the 2D noise variance, potentially separately for each point. I ended up with something reasonable, that looks a little off sometimes, and also never varies too far from the expected shape, like real puzzles do. A tangent on the "multiple solutions" thing - some large commercial puzzles are (evidently) larger than the maximum die size, so they are cut with multiple copies of the same pattern. A 5000-piece puzzle might have four copies in a 2x2 grid.
- kuu 7y agoA bit off topic but I liked that you don't force the newsletter or recommended articles in your blog. The links are there and I can visit them if I like them, but I don't feel forced. This is the way it should be. Thank you!
- theon144 7y agoVery nice write-up! I'm surprised it was this simple (which is a compliment!), and I learned about "Whimsy pieces" :)
- sanj 7y agoWhen I’ve tried to cut a jigsaw with a laser, the kerf between pieces was too large and it fit together a little too loosely to have that satisfying “snap” when pieces came together. Has anyone had/fixed that problem?
- SCLeo 7y ago> Add more curves and it gets even better! Honestly, I think it looks better before adding more curves. :|