xxxxxxxxxx
46
let drawing = false;
let brushSize = 27;
let colors = ['#E48181', '#5BDF5B', '#0000FF', '#2196F3', '#FF00FF', '#00FFFF', '#21887E', '#E795B1', '#FAF2B0', '#00FFFF'];
let currentColor;
function setup() {
createCanvas(400, 400);
background(255);
currentColor = random(colors);
}
function draw() {
// Display the current brush color
noStroke();
fill(currentColor);
ellipse(mouseX, mouseY, brushSize, brushSize);
}
function mousePressed() {
drawing = true;
}
function mouseReleased() {
drawing = false;
// Change the brush color after releasing the mouse
currentColor = random(colors);
}
function mouseDragged() {
if (drawing) {
// Draw when the mouse is dragged
noStroke();
fill(currentColor);
ellipse(mouseX, mouseY, brushSize, brushSize);
}
}
// Change brush size with '+' and '-' keys
function keyPressed() {
if (key === '+') {
brushSize += 10;
} else if (key === '-' && brushSize > 5) {
brushSize -= 5;
}
}