//String Art V4 // Version 1: Vary the stroke color // Version 2: Vary the radius of lines a little // Version 3: Vary the distance (angle) between lines using noise // Version 4: Jiggle the center point a little float angle; float radius; float cx, cy; float x1, y1, x2, y2; float strokeColor; float strokeDelta; // Define this (V1) float radiusNoise; // Add noise to radius (V2) float angleNoise; // The noise period of angle variation (V3) float xNoise; // For jiggling the center a little (V4) float yNoise; void setup() { size(500, 500); smooth(); background(255); // Initial settings cx = width/2; cy = height/2; radius = width/2; angle = 0; // degrees strokeColor = 0; strokeDelta = 1; // stroke color will change by 1 (V1) radiusNoise = random(10); // Variation in radius (V2) angleNoise = random(10); // angle noise...(V3) xNoise = random(10); // For the center jiggle (V4) yNoise = random(10); } // setup void draw() { //angle = angle - 3; // from (V1)..changes to version below // compute angle (V3) angleNoise += 0.005; angle = angle + noise(angleNoise)*6 - 3; if (angle > 360) { angle = angle - 360; } if (angle < 0) { angle = angle + 360; } float theta = radians(angle); // vary the radius a little (V2) radiusNoise += 0.005; radius = noise(radiusNoise)*width/2; // compute the center using jiggle (V4) xNoise += 0.01; yNoise += 0.01; cx = width/2 + noise(xNoise)*50 - 25; cy = height/2 + noise(yNoise)*50 - 25; // compute the end points of line x1 = cx + radius * cos(theta); y1 = cy + radius * sin(theta); x2 = cx + radius * cos(theta+PI); y2 = cy + radius * sin(theta+PI); // Draw the line // Modify stroke color properties (V1) strokeColor = strokeColor + strokeDelta; if (strokeColor > 255 || strokeColor < 0) { strokeDelta = strokeDelta * -1; } stroke(strokeColor, 60); // Also add some transparency (V4) strokeWeight(1); line(x1, y1, x2, y2); } // draw()