xxxxxxxxxx
35
var points = [];
var playbackIndex = 0;
function setup() {
createCanvas(400, 400);
}
function draw() {
background(200);
noFill();
beginShape();
for (var i=0; i<points.length; i++){
vertex(points[i].x, points[i].y);
}
endShape();
var px = width/2;
var py = height/2;
if (points.length > 0){
px = points[playbackIndex].x
py = points[playbackIndex].y;
playbackIndex = (playbackIndex+1)%(points.length);
}
fill(255);
ellipse(px,py, 40, 40);
}
function mousePressed(){
playbackIndex = 0;
points = [];
}
function mouseDragged(){
points.push(createVector(mouseX, mouseY));
}