This library is specifically written to be useful for a broad range of ways in which I create art using various generative algorithms.
In short snek is four things:
-
A simple (graph) data structure for working with vertices and edges The structure is named
snek; the name is explained below. This structure is combined with a programming pattern for applying changes to the structure. The pattern relies onalterations, see below. -
A series of useful data structures and tools. E.g. a 2D vector
vec, a package for generating different kinds of random numbers:rnd, as well as tools for handling colors (pigment), splines (bzspl), and various vector an path functionality (math,lin-path). -
A tool for drawing things called
sandpaint.sandpaintuses random sampling to draw its primitives. This creates a fairly distinct and gritty look in many cases. -
A tool for drawing svg files (
draw-svg). Mainly svg files that are good for plotting.
A while back someone on Twitter suggested that if Python 3 was named "snek" it
would avoid naming confusion. I found that amusing at the time, and picked
snek as the placeholder name for this project. I've been looking for a better
name, but I haven't found one yet.
The pattern depends on the concept of alterations. In short: an alteration
is a change that will be applied to the structure at the end of a given
context. alterations are further described in
https://inconvergent.net/2017/snek-is-not-an-acronym/.
I have also written about things related to snek at
- https://inconvergent.net/2017/a-propensity-for-mistakes/ (indirectly about
snek) - https://inconvergent.net/2017/a-method-for-mistakes/
- https://inconvergent.net/2017/arbitrary-alterations/
- https://inconvergent.net/2017/grains-of-sand/
Here is and example of manipulating a snek instance called snk using
alterations. Alteration constructors are postfixed with ?.
; context start
(snek:with (snk)
; iterate vertices
(snek:itr-verts (snk v)
; move alteration
(snek:move-vert? v (rnd:in-circ 1d0))
; w will be an arbitrary
; vertex in snk
(snek:with-rnd-vert (snk w)
; join v and w if they are closer than d
(if (< (snek:edge-length snk v w) d)
; join vertices alteration
(snek:add-edge? v w))))
; context end
; alterations have been appliedYou can also manipulate the state directly. These functions are postfixed with
!. Eg. (snek:move-vert! ...).
There are some examples included. All examples are in the examples folder.
If you don't provide a filename (with full or relative path) as the first
argument, the resulting file will be named ./tmp.png.
You can define your own arbitrary alterations. There is an example of this in
ex/custom-alt.lisp. I have also written about it here:
https://inconvergent.net/2017/arbitrary-alterations/
I use snek for most of the work that I post online (https://twitter.com/inconvergent). Both for generating raster images as well as vector images for plotter drawings.
Here are some plotted examples:
- https://inconvergent.net/2017/spline-script-plots/
- https://inconvergent.net/mechanical-plotter-drawings/
- https://inconvergent.net/mechanical-plotter-drawings/3/
- https://inconvergent.net/mechanical-plotter-drawings/5/
This code requires libpng-dev, Quicklisp, zpng, cl-svg and cl-png.
The path to quicklisp must be set in src/load. zpng, cl-svg and cl-png
are automatically installed via quicklisp.
- https://www.quicklisp.org/beta/
- http://www.xach.com/lisp/zpng/
There are some tests included, see the test folder.
This code is highly experimental on my part. It is likely to change with no
warning or explanation. I will keep a note of the version number in
src/load.lisp.
I would like to thank:
- https://twitter.com/RainerJoswig
- https://twitter.com/paulg
- https://twitter.com/jackrusher
Who have provided me with useful hints and code feedback.



