xxxxxxxxxx
28
class HSlider {
constructor(x1, x2, d) {
this.x1 = x1;
this.x2 = x2;
this.d = d;
textAlign(CENTER);
}
show() {
let mapX = map(mouseX, 0, width, this.x1, this.x2);
strokeWeight(5);
stroke(0);
line(this.x1, height / 2, this.x2, height / 2);
stroke(255);
strokeWeight(1);
if (mapX >= this.x2) {
mapX = this.x2;
circle(mapX, height / 2, this.d);
} else {
circle(mapX, height / 2, this.d);
}
noStroke();
text(round(mapX), mapX, height / 2 - 15);
}
}