// StringArt: Start of something fun
// First, lets just draw a line centered at cx, cy
// then rotate it by a delta
// Then, add the following incrementally
// Version 1: Drawing several lines by varying the angle
// version 2: Adding some noise to the line tilt angle
// version 3: Adding some noise to the radius (line length)
// Version 4: Add soem noise to center placement (jiggle the line)
// Version 5: Finishing touch: Vary StrokeColor
float cx, cy;
float lineLength, radius;
float theta, delta;
float angleNoise;    // V2 Angle Noise
float radiusNoise;  // V3 radius noise
float xNoise;    // V4 center noise
float yNoise;
int strokeColor;    // V5 Stroke Color changes
int strokeDelta;
void setup() {
   size(500, 500);
   smooth();
   background(200);
   // set up variables
   cx = width/2;
   cy = height/2;
   lineLength = width-100;
   radius = lineLength/2;
   theta = random(360);
   delta = 2;          // V1: Add a delta change to angle
   angleNoise = random(10);  // V2 set initial value
   radiusNoise = random(10);  // V3 radius noise
   xNoise = random(10);    // V4 center noise
   yNoise = random(10);      // V4
   strokeColor = 0;  // V5 Stroke Color 
   strokeDelta = 1;
} // setup()
void draw() {
   // compute angle by adding some Perlin Noise ---V2
   angleNoise += 0.005;
   theta = theta + noise(angleNoise)*6 - 3;
   if (theta > 360) {
      theta = theta - 360;
   }
   if (theta < 0) {
      theta = theta + 360;
   }
   // compute the radius  ----V3
   radiusNoise += 0.005;
   radius = noise(radiusNoise)*width/2;
   // compute the center    ---V4
   xNoise += 0.01;
   yNoise += 0.01;
   cx = width/2 + noise(xNoise)*50 - 25;
   cy = height/2 + noise(yNoise)*50 - 25;
   // draw line
   float angle = radians(theta);
   float x1 = cx + radius * cos(angle);
   float y1 = cy + radius * sin(angle);
   float x2 = cx + radius * cos(angle+PI);
   float y2 = cy + radius * sin(angle+PI);
   //stroke(0);
   // set its color etc.    // V5
   strokeColor += strokeDelta;
   if (strokeColor > 255 || strokeColor < 0) {
      strokeDelta = strokeDelta * -1;
   }
   stroke(strokeColor, 60);
   line(x1, y1, x2, y2);
   theta += delta;    // Increment angle by delta
} // draw()