PImage danimage; int index; void setup() { size(400,400); //size of window noSmooth(); //no antialiasing on edges causes program to fun faster fill(0); //color of background danimage = loadImage("danimage.jpg"); //loads image in variable danimage danimage.loadPixels(); //loads pixel data from danimage variable into pixels[] array } void draw() { float rnd = random(400); //creates random variable from 0-400 background(255,mouseX,mouseY); //background color controlled by user mouse control int mx = constrain (mouseX,0,danimage.width-1); //sets a constrained value into mx with a minimum and maximum limit to mouseX int offset = mx *danimage.width; //sets a value into offset beginShape(LINES); //beginShape allows creation of more complex forms, this time being lines for (int i = 0; i < danimage.width; i += 2){ //beginning of for loop for assigning values float r1 = blue(danimage.pixels[offset + i]); //reads pixel array data for blue color and adds to variable i which is used in below variable assignments float r2 = blue(danimage.pixels[offset + i + 1]); //same as top float tx = map(rnd,0,255,0,height); //x coordinate used in vertex below float ty = map(r2,0,255,0,height); //y coordinate float ux = map(0,255,0,r1,height); //x coordinate float uy = map(0,255,0,r2,height); //y coordinate float vx = map(255,r1,0,0,height); //x coordinate float vy = map(255,r2,0,0,height); //y coordinate vertex(tx,ty); //specifies vertex coordinates for LINES function called by the above beginShape vertex(ux,uy); //same as above vertex(vx,vy); //same as above } endShape(); //ends LINES color c = danimage.pixels[index]; //associates all pixel color values of danimage.pixels[] array in variable c float g = green(c) / rnd; //g is assigned all green values of c(see above for description of c) ellipse (mouseX, mouseY, mouseY,mouseX); //ellipse drawn with user mouse input index++; //adds 1 to index if (index == width*height) { //starts index loop to figure out if index equals screen area index = 0; //resets index value } }