Libraries I use for generative art
I finally settled with these libraries after trying several other alternatives for each. Performance was one of the key factors (especially as generative work can get brute-forcy sometimes).
Huge thank you to all people who created and shared these wonderful tools! (Also, as a rule of thumb, when you find a good library, you might want to check author's GitHub profile. In the most cases you are going to find more useful stuff there. That is exactly how I found some of these.)
In generative programming it is super important to be able to repeat the same output. As randomness is heavily involved, we need a way to repeat random values. That's where seedrandom steps in as an excellent seeded random number generator.
For random number generator seeds, I like to use real words instead of randomly generated strings. This library is a simple dictionary of couple of thousands english words.
Fast implementation of Open Simplex and Perlin noise.
When you need a random collections of points in space, Poisson sampling is a great tool. It gives us much more natural distribution than just using random values.
This library is a lifesaver. For all your polygon clipping and offseting needs. And it is super fast as it is implemented in WebAssembly.
Sometimes I think I use Voronoi diagrams too much in my work. Anyway, this library efficiently computes Voronoi diagrams.
For figuring out if the point is inside of the polygon. I tried a couple of other libraries and all of them would return wrong results in certain edge cases. So far,
robust-point-in-polygon didn't let me down.
Simplifies polyline. Very useful for pen plotting. Sometimes my programs would generate lines with way too many points. This library will reduce the number significantly and human eye often can't see the difference.
Finds all intersections of a given set of line segments.
Calculates stream lines for a given vector field.
This is my port of Michael Fogleman's ln from Go to TypeScript. It was never fully finished, so you might want to check another port - ln.js. It is complete and has better documentation than my port. Personally, I still use mine as it is easier for me to hack around.
When working with spatial data, something that is a trivial problem to a human to see, can be super hard to code. These two libraries make things like searching for nearby elements in space so much easier.
K-dimensional tree implementation. It is space-partitioning data structure for organizing points in a k-dimensional space.
2D spatial indexing which uses R-tree.
All of my work is plotted using AxiDraw. Saxi is a great little program that lets you control AxiDraw. It comes with a great set of default values for options. Depending on the scenario, it can make plotting a much more pleasant experience than official Inkscape plugin.
Memoization of functions. It means that consecutive function calls with identical input are cached instead of calculated again.
cause why not? Just kidding. To make navigation through the history easier, for each unique combination of parameters I generate a random color and ASCII face. Then my browser history looks like this: