Pattern Generation for Computational Art
Software
Below are the C programs that accompany the book, Pattern Generation for Computational Art. You can download each as you need it, or all of them bundled into a zip file. All the automaton files used in the book can also be downloaded in a zip file.
This software is free and distributed under the terms of the GNU General Public License. It is written in ANSI C and should compile with any C compiler. If you have questions or comments contact: Stefan (stefan at exstrom dot com) or Richard (richard at exstrom dot com).
Update
As of Feb 2024, we've created a new version of turtledraw.c that does not depend on the Cairo graphics library. The new program is turtledrawnc.c where the "nc" means "no cairo". This program has extra command line parameters (see usage below), but it can be used in place of turtledraw.c.
- autogen.c
Generates all words of a given length accepted by an automaton.
Usage: autogen file.aut n s e1 e2 ... file.aut = automaton file n = length of words s = start state ei = end state i
- b2d.c
Converts a binary number to decimal.
Usage: d2b n
- cfcv.c
Calculates the convergent of a continued fraction.
Usage: cfcv a0 a1 a2 ... an ai = simple continued fraction term
- cfgen.c
Generates the words of a context free grammar.
Usage: cfgen file.cfg n s file.cfg = grammar file n = number of derivation steps s = start variable
- cfrac.c
Calculates the continued fraction of a real number.
Usage: cfrac x n x = number n = number of terms
- cfrat.c
Calculates the continued fraction of the rational number p/q.
Usage: cfrat p q
- cfsqrt.c
Calculates the continued fraction of the square root of an integer.
Usage: cfsqrt n n = integer
- cfsurd.c
Calculates the continued fraction of a quadratic surd: (A+sqrt(n))/B where n, A and B are integers and n>0.
Usage: cfsurd n A B n, A, B = integers, with n>0
- chseq.c
Calculates a Christoffel sequence.
Usage: chseq p q n p = numerator q = denominator n = number of terms to generate, default=p+q
- d2b.c
Converts a decimal number to binary.
Usage: d2b n
- katrans.c
Translates a sequence of the numbers 0 to k.
Usage: katrans file.kat file.kat = k-automaton file
- lsysgen.c
Generates an L-system string given an axiom and set of production rules.
Usage: lsysgen file.ldf n file.ldf = name of file with axiom and production rules. n = number of times to iterate.
- pfold.c
Generates paper folding sequences.
Usage: pfold n m f n = number of terms, 1,3,7,15,31,63,127,... m = number of bits f = function number 0 -> 2^m-1
- rndseq.c
Generates random binary sequences.
Usage: rndseq n n = number of digits to generate
- rsseq.c
Generates the Rudin-Shapiro sequence.
Usage: rsseq n n = number of terms
- tmseq.c
Generates the Thue-Morse sequence.
Usage: tmseq n n = number of terms
- turtledraw.c
Creates an svg file from turtle drawing instructions. Input is read from stdin.
Requires the Cairo graphics library.
Usage: turtledraw angle dangle file.svg angle = start angle dangle = increment angle file.svg = output svg file. Example: chseq 355 113 1872 | katrans t7.kat | turtledraw 0.0 90.0 file.svg
- turtledrawnc.c
Creates an svg file from turtle drawing instructions. Input is read from stdin.
Output is written to stdout. This program has extra command line parameters,
but it can be used in place of turtledraw.c.
It does not depend on the Cairo graphics library.
Usage: turtledrawnc width height units sw angle dangle length width = width of canvas in given units. height = height of canvas in given units. units = px pt pc cm mm in. sw = stroke width in given units. angle = start angle. dangle = increment angle. length = line length. Example: chseq 355 113 1872 | katrans t7.kat | turtledrawnc 16 16 cm 0.1 0.0 90.0 1.0 > out.svg
Send comments to: Richard Hollos (richard[AT]exstrom DOT com)
Copyright 2019 by Exstrom Laboratories LLC