Published
Edited
Nov 9, 2021
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
mutable lastMouseX = 0
Insert cell
mutable lastMouseY = 0
Insert cell
mutable angle1 = 0.0
Insert cell
mutable angle2 = 0.0
Insert cell
mutable listenerIsSet = false
Insert cell
{
if (listenerIsSet)
return;
canvas.addEventListener('mousemove', onMouseMove, false);
mutable listenerIsSet = true;
}
Insert cell
onMouseMove = (event) => {
let mouseX = event.clientX;
let mouseY = event.clientY;

let diffX = mouseX - lastMouseX;
let diffY = mouseY - lastMouseY;

mutable angle1 = angle1 + diffX/2.5;
mutable angle2 = angle2 + diffY/2.5;

mutable lastMouseX = mouseX;
mutable lastMouseY = mouseY;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more