xxxxxxxxxx
39
function setup() {
createCanvas(400, 400);
x = 50
y = height / 2
}
function draw() {
//the line the slider glides on
background(220);
strokeWeight(7);
line(50,200, 350,200);
//the slider thingy
rectMode(CENTER);
rect(x, y, 28, 50);
print(mouseX, mouseY);
//slider functionality
if (mouseIsPressed) {
x = mouseX;
//make it stay on the slider
if (mouseX < 50) {
x = 50
}
if (mouseX > 350) {
x = 350
}
}
}