xxxxxxxxxx
32
drawing=[];
function setup() {
createCanvas(400, 400);
}
function draw() {
background(0);
strokeWeight(10);
for(let i=0;i<drawing.length;i++){
if(drawing[i].length >0){
let px= drawing[i][0].x;
let py= drawing[i][0].y;
for (let j=0;j<drawing[i].length;j++){
stroke(drawing[i][j].col);
line(px,py,drawing[i][j].x,drawing[i][j].y);
px=drawing[i][j].x;
py=drawing[i][j].y;
}
}
}
}
function mousePressed(){
drawing.push([])
}
function mouseDragged(){
drawing[drawing.length-1].push({x:mouseX,y:mouseY,col:color(random(0,255),random(0,255),random(0,255))});
}