blob: e5c7f5b762a15a025b6db35c3dcd930c6f6f37e5 (
plain) (
blame)
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
|
import { FEATHER_HANDLE_SCALE, MAX_FEATHER } from "@/masks/feather";
export function computeFeatherUpdate({
startFeather,
deltaX,
deltaY,
directionX,
directionY,
}: {
startFeather: number;
deltaX: number;
deltaY: number;
directionX: number;
directionY: number;
}): { feather: number } {
const projection = deltaX * directionX + deltaY * directionY;
return {
feather: Math.max(
0,
Math.min(
MAX_FEATHER,
Math.round(startFeather + projection / FEATHER_HANDLE_SCALE),
),
),
};
}
|