let drawing = false; | |
let lastX, lastY; | |
function setup() { | |
createCanvas(400, 400); | |
background(100); // White background | |
} | |
function draw() { | |
if (drawing) { | |
stroke(0); // Black stroke color | |
strokeWeight(4); // Thicker line | |
line(mouseX, mouseY, pmouseX, pmouseY); | |
} | |
} | |
function mousePressed() { | |
drawing = true; | |
lastX = mouseX; | |
lastY = mouseY; | |
} | |
function mouseReleased() { | |
drawing = false; | |
} | |
function mouseDragged() { | |
if (drawing) { | |
stroke(0); // Black stroke color | |
strokeWeight(4); // Thicker line | |
line(lastX, lastY, mouseX, mouseY); | |
lastX = mouseX; | |
lastY = mouseY; | |
} | |
} |