Skip to content

Instantly share code, notes, and snippets.

@claytical
Created September 28, 2015 22:21
Show Gist options
  • Save claytical/c0c56be647a415c32863 to your computer and use it in GitHub Desktop.
Save claytical/c0c56be647a415c32863 to your computer and use it in GitHub Desktop.
Saving Points Example
var xPoints = [];
var yPoints = []
function setup() {
createCanvas(windowWidth, windowHeight);
}
function draw() {
background(0);
stroke(255);
for (var i = 0; i < xPoints.length; i++) {
ellipse(xPoints[i], yPoints[i], 5, 5);
if (xPoints.length > 1) {
line(xPoints[i], yPoints[i], xPoints[i + 1], yPoints[i+1]);
}
}
}
function mousePressed() {
xPoints.push(mouseX);
yPoints.push(mouseY);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment