xxxxxxxxxx
27
var x;
var offset = 10;
function setup() {
createCanvas(240, 120);
x = width / 2;
}
function draw() {
background(220);
if (mouseX > x) {
x += 0.5;
offset = -10;
}
if (mouseX < x) {
x -= 0.5;
offset = 10;
}
line(x, 0, x, height);
// draw arrow left/right depending on "offset" value
line(mouseX, mouseY, mouseX + offset, mouseY - 10);
line(mouseX, mouseY, mouseX + offset, mouseY + 10);
line(mouseX, mouseY, mouseX + offset*3, mouseY);
}