Created
April 15, 2014 03:34
-
-
Save atduskgreg/10699977 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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