xxxxxxxxxx
30
let x = 50;
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
fill(x, x, x);
rect(0, 0, width, height);
// Slider frame
fill(0);
stroke(0);
strokeWeight(1);
rect(75, 200, 240, 30, 20);
// Slider move
noStroke();
fill(300);
rect(75, 200, x, 30, 20);
// When mouse is pressed, move with mouse x
if (mouseIsPressed === true) {
x = constrain(mouseX - 50, 50, 250);
}
}