Skip to content

Instantly share code, notes, and snippets.

@atduskgreg
Created April 15, 2014 03:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atduskgreg/10699977 to your computer and use it in GitHub Desktop.
Save atduskgreg/10699977 to your computer and use it in GitHub Desktop.
p = []
lastMouse = false;
function setup(){
resetDrawing();
}
function draw(){
if(mouseIsPressed()){
p[p.length-1].push({x: mouseX, y: mouseY});
lastMouse = true;
} else {
if(lastMouse){
p.push([]);
}
}
stroke(255);
strokeWeight(2);
for(var i = 0; i < p.length; i++){
beginShape();
for(var j = 0; j < p[i].length; j++){
vertex(p[i][j].x, p[i][j].y);
}
endShape();
}
}
function resetDrawing(){
p = [];
p.push([]);
c = $("canvas")[0]
c.width = c.width;
background(0,125);
}
function keyPressed(){
if(key == ' '){
resetDrawing();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment