Begin breaking up the API file

This commit is contained in:
2024-04-14 21:15:36 +02:00
parent a21d6c9a88
commit 0a6d779867
29 changed files with 2197 additions and 2729 deletions

33
src/API/Mouse.ts Normal file
View File

@ -0,0 +1,33 @@
// mouse.ts
export const onmousemove = (app: any) => (e: MouseEvent): void => {
app._mouseX = e.pageX;
app._mouseY = e.pageY;
};
export const mouseX = (app: any) => (): number => {
/**
* @returns The current x position of the mouse
*/
return app._mouseX;
};
export const mouseY = (app: any) => (): number => {
/**
* @returns The current y position of the mouse
*/
return app._mouseY;
};
export const noteX = (app: any) => (): number => {
/**
* @returns The current x position scaled to 0-127 using screen width
*/
return Math.floor((app._mouseX / document.body.clientWidth) * 127);
};
export const noteY = (app: any) => (): number => {
/**
* @returns The current y position scaled to 0-127 using screen height
*/
return Math.floor((app._mouseY / document.body.clientHeight) * 127);
};