Generative art experiment 2: Pinkchalk spiral
January 12, 2012
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
float oldx = -999; float oldy = -999; float x; float y; int colour = 0; void setup () { smooth(); size (600, 600); drawit (); } void drawit () { background(155); oldx = -999; oldy = -999; colour = 0; int spirals = floor(random(500)); println("drawing" + spirals); for (int i = 0; i < spirals; i++) { stroke (colour, 0, random(colour), 10); strokeWeight(random(i / 10)); spiral (); colour+=255/spirals; } } void spiral () { float variance = random(360); float angle = variance; float r = 0; float endangle = random(1500) + variance; float inc = random (1.6) - 0.8; while (abs(angle) < endangle) { x = cos(radians(angle)) * r + random(10); y = sin(radians(angle)) * r + random(10); if (abs(oldx) > -999) { line (x + width/2, y+ height/2, oldx + width/2, oldy + height/2); } oldx = x + cos(radians(angle)); oldy = y + sin(radians(angle)); angle+=inc; r+=.1; } } void draw () { } void keyPressed () { if (keyCode == DOWN) { drawit (); } if (keyCode == RETURN || keyCode == ENTER) { saveFrame ("frame-####.tiff"); } } |