blob: e91c5e4b2b79813f4e3487ef82626c10cd7f8c62 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
function randomAngle() {
return Math.random() * Math.PI * 2;
}
function toDegrees(radians) {
return radians * 180 / Math.PI;
}
function toDegreesInt(radians) {
return Math.floor(toDegrees(radians));
}
function normalizeAngle(radians) {
return (radians + Math.PI) % (2 * Math.PI) - Math.PI;
}
function drawSquare(ctx, v2, size) {
const off = size / 2;
ctx.fillRect(v2.x - off, v2.y - off, size, size);
}
export {
randomAngle,
toDegrees,
toDegreesInt,
normalizeAngle,
drawSquare,
}
|