Begin breaking up the API file
This commit is contained in:
33
src/API/Mouse.ts
Normal file
33
src/API/Mouse.ts
Normal 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);
|
||||
};
|
||||
Reference in New Issue
Block a user