Skip to content

Instantly share code, notes, and snippets.

@geoffa
Created December 9, 2009 22:03
Show Gist options
  • Save geoffa/252876 to your computer and use it in GitHub Desktop.
Save geoffa/252876 to your computer and use it in GitHub Desktop.
PImage subject;
float baseStart;
float baseLength;
float xVector;
float yVector;
float hStart;
float hLength;
void setup() {
size(600, 440);
background(128);
subject = loadImage("trey.jpg");
image(subject, 0, 0);
stroke(0, 0, 0, 75);
smooth();
baseStart = 3;
baseLength = 20;
}
void draw() {
hStart = random(-baseStart, baseStart);
hLength = random(baseLength);
if (mousePressed == true) {
if (mouseX>=width/2) {
xVector = random(hLength);
} else {
xVector = -random(hLength);
}
if (mouseY>=height/2) {
yVector = random(hLength);
} else {
yVector = -random(hLength);
}
line(mouseX+hStart, mouseY+hStart, mouseX+xVector, mouseY+yVector);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment