Generative art experiment 2: Pinkchalk spiral
January 12, 2012
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");
}
}