Generative Art With Haskell: A Start
These notes are nothing more than a work-through of the beautiful example of generative art by Benjamin Kovach — and a warm-up for future work. If you are interested in this kind of art, I highly recommend his post. Below is one piece produced by Kovach’s program. It uses a random seed, so each time you run the program, you will get a different result.
The program is written in Haskell, with which I have
little experience — Elm is the FP language that I work
with the most. In case there are other Haskell newbies
out there who want to try their hand at generative art,
I’ve posted the code on GitHub.
Look in at Main.hs
Some comments on installing it below.
I heard Kovach speak at Strangeloop in St. Louis last year. His talk was a fine balance of history, esthetics, and code. The Cairo library which he uses to render his art is very fast (written in C).
Installing the program
I’ll have better instructions soon when I install this
on a clean machine. The biggest stumbling block for
me was in dealing with the various dependencies. For the
most part, they are listed in
package.yaml. A few
packages required a new entry in the
the GitHub repo
The algorithm I used to set up the dependencies was (a)
stack build; (b) scratch head while studying the
error messages; (c) search (Google, Hackage) for the
package name; (d) make a guess and add to
(e) Go to (a) unless done.
Once the build process ran without error, I ran
The output appears in
A good piece of art is usually still a pretty good piece of art when it is desaturated so as to give a grayscale image. Then one sees only a pattern of light and dark values. Strong compositions generally are almost always ones that are still strong when viewed this way.