// Purpose: String Art float angle; float radius; float cx, cy; int strokeColor; int strokeDelta; float radiusNoise; float angleNoise; float xNoise; float yNoise; void setup() { size(500, 500); smooth(); background(255); // initial values cx = width/2; cy = height/2; angle = 0.0; // degrees radius = width/2; strokeColor = 0; strokeDelta = 1; radiusNoise = random(10); angleNoise = random(10); xNoise = random(10); yNoise = random(10); } // setup() void draw() { // compute angle angleNoise += 0.005; angle = angle + noise(angleNoise)*6 - 3; if (angle > 360) { angle = angle - 360; } if (angle < 0) { angle = angle + 360; } // compute the radius radiusNoise += 0.005; radius = noise(radiusNoise)*width/2; // compute the center xNoise += 0.01; yNoise += 0.01; cx = width/2 + noise(xNoise)*50 - 25; cy = height/2 + noise(yNoise)*50 - 25; // compute line float theta = radians(angle); float x1 = cx + radius * cos(theta); float y1 = cy + radius * sin(theta); float x2 = cx + radius * cos(theta + PI); float y2 = cy + radius * sin(theta + PI); // set its color etc. strokeColor += strokeDelta; if (strokeColor > 255 || strokeColor < 0) { strokeDelta = strokeDelta * -1; } stroke(strokeColor, 60); // draw line line(x1, y1, x2, y2); } // draw()