# From: # www.contextfreeart.org/gallery2/#design/3910
startshape BIT(0, (0,1,2,3,4)) []
CF::MaxNatural = 9007199254740992
// The shape BIT is a finite-state machine that // produces random but structured patterns
// BIT draws a TILE and then alters the vector // parameter according to the state specified by v
// The pattern starts at the lower left pixel and // walks to the right - moving up and returning to // the left when n == row size
num_steps = 1089 row_size = 33
//Some alternative canvas sizes
//num_steps = 400 //row_size = 20
//num_steps = 10000 //row_size = 100
//num_steps = 9801 //row_size = 99
shape BIT(natural n, vector5 v) {
if(n < num_steps) { //Draw tile in proper position TILE(v[0])[ x mod(n, row_size) y floor((n/row_size)) ] //every 26 steps repeat the current state if (mod(n,26) == 0 ) { BIT(n+1, (v[0],v[1],v[2],v[3],v[4]) )[] } //state 0 == reverse direction else if (v[0] == 0 ) { BIT(n+1, (v[4],v[3],v[2],v[1],v[0]) )[] } //state 0 == swap next and previous states else if (v[0] == 2 ) { BIT(n+1, (v[1],v[4],v[2],v[3],v[0]) )[] } //default state - cycle the vector else { BIT(n+1, (v[1],v[2],v[3],v[4],v[0]) )[] } }
}
shape TILE(number state) {
if (state == 0 ) { SQUARE[h 43.08 sat 0.1797 b 0.7] } if (state == 1 ) { SQUARE[h 44.52 sat 0.4 b 0.5804] } if (state == 2 ) { SQUARE[h 146.67 sat 0.1 b 0.4] } if (state == 3 ) { SQUARE[h 35.38 sat 0.3197 b 0.4784] } if (state == 4 ) { SQUARE[h 190.00 sat 0.1639 b 0.14] }
}