escalator-web/src/utils.js

26 lines
519 B
JavaScript

function isInBox(pos, box) {
return (
(pos.x > box.x && pos.x < box.x + box.width) &&
(pos.y > box.y && pos.y < box.y + box.height));
}
function position(event) {
return {
x: event.clientX,
y: event.clientY,
};
}
function enlargeBox(box) {
return {
x: box.x - box.width * 0.1,
y: box.y - box.height * 0.1,
width: box.width * 1.2,
height: box.height * 1.4,
}
}
function heightToScore(height) {
return Math.floor(100 * height);
}