kanat is too fat
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

14 lines
458 B

function screen_to_canvas(p) {
// should be called with coordinates obtained from MouseEvent.clientX/clientY * window.devicePixelRatio
const xc = (p.x - offset.x) / zoom;
const yc = (p.y - offset.y) / zoom;
return {'x': xc, 'y': yc};
}
function canvas_to_screen(state, p) {
const xs = (p.x * zoom + offset.x) / window.devicePixelRatio;
const ys = (p.y * zoom + offset.y) / window.devicePixelRatio;
return {'x': xs, 'y': ys};
}