MCPcopy Create free account
hub / github.com/Code-Bullet/Jump-King / getMousePos

Function getMousePos

libraries/p5.js:18958–18976  ·  view source on GitHub ↗
(canvas, w, h, evt)

Source from the content-addressed store, hash-verified

18956};
18957
18958function getMousePos(canvas, w, h, evt) {
18959 if (evt && !evt.clientX) { // use touches if touch and not mouse
18960 if (evt.touches) {
18961 evt = evt.touches[0];
18962 } else if (evt.changedTouches) {
18963 evt = evt.changedTouches[0];
18964 }
18965 }
18966 var rect = canvas.getBoundingClientRect();
18967 var sx = canvas.scrollWidth / w;
18968 var sy = canvas.scrollHeight / h;
18969 return {
18970 x: (evt.clientX - rect.left) / sx,
18971 y: (evt.clientY - rect.top) / sy,
18972 winX: evt.clientX,
18973 winY: evt.clientY,
18974 id: evt.identifier
18975 };
18976}
18977
18978p5.prototype._setMouseButton = function(e) {
18979 if (e.button === 1) {

Callers 1

p5.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected