def draw background(237, 34, 93) fill(0) # draw a square only if the mouse is not moving if mouseY == pmouseY && mouseX == pmouseX rect(20, 20, 60, 60) end end
[p5.js] pmouseY
マウスポインタの1フレーム前の y座標の値が格納されているシステム変数です。