Sooo, this is not a solution, but it may be(?) a prompt in how to start to think about an approach to a solution…
Includes 2 states but not a third transitional triangle state, plus the tracking across the screen is not proper.
Here’s some p5.js code that you can copy and modify. Try to add what is necessary to draw the triangle, and refine the rest to suit your needs and taste.
let curr_x, prev_x, size;
function setup() {
createCanvas(600, 400);
curr_x = width / 2;
prev_x = curr_x;
size = 50;
rectMode(CENTER);
}
function draw() {
/*
- ellipse as mouse moves left
- rect as mouse moves right
- triangle if there is no mouse movement
*/
background(220);
fill(0);
noStroke();
prev_x = curr_x;
curr_x = mouseX;
if (curr_x < prev_x) {
ellipse(curr_x, mouseY, size, size);
} else if (curr_x > prev_x) {
rect(curr_x, mouseY, size, size);
} else {
// draw triangle (for you to complete :) )
}
}