|
|
@ -145,6 +145,8 @@ function keydown(e, state, context) { |
|
|
|
enter_picker_mode(state, context); |
|
|
|
enter_picker_mode(state, context); |
|
|
|
} else if (e.code === 'KeyD') { |
|
|
|
} else if (e.code === 'KeyD') { |
|
|
|
document.querySelector('.debug-window').classList.toggle('dhide'); |
|
|
|
document.querySelector('.debug-window').classList.toggle('dhide'); |
|
|
|
|
|
|
|
} else if (e.code === 'KeyZ') { |
|
|
|
|
|
|
|
state.zoomdown = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -155,6 +157,8 @@ function keyup(e, state, context) { |
|
|
|
context.canvas.classList.remove('movemode'); |
|
|
|
context.canvas.classList.remove('movemode'); |
|
|
|
} else if (e.code === 'ControlLeft' || e.code === 'ControlRight') { |
|
|
|
} else if (e.code === 'ControlLeft' || e.code === 'ControlRight') { |
|
|
|
exit_picker_mode(state); |
|
|
|
exit_picker_mode(state); |
|
|
|
|
|
|
|
} else if (e.code === 'KeyZ') { |
|
|
|
|
|
|
|
state.zoomdown = false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -181,6 +185,12 @@ function mousedown(e, state, context) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (state.zoomdown) { |
|
|
|
|
|
|
|
state.zooming = true; |
|
|
|
|
|
|
|
state.canvas.zoom_screenp = screenp; |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (state.colorpicking) { |
|
|
|
if (state.colorpicking) { |
|
|
|
const color_u32 = color_to_u32(state.color_picked.substring(1)); |
|
|
|
const color_u32 = color_to_u32(state.color_picked.substring(1)); |
|
|
|
state.players[state.me].color = color_u32; |
|
|
|
state.players[state.me].color = color_u32; |
|
|
@ -264,6 +274,30 @@ function mousemove(e, state, context) { |
|
|
|
update_color_picker_color(state, context, canvasp); |
|
|
|
update_color_picker_color(state, context, canvasp); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (state.zooming) { |
|
|
|
|
|
|
|
const zooming_in = e.movementY > 0; |
|
|
|
|
|
|
|
const zooming_out = e.movementY < 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let zoom_level = null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (zooming_in) { |
|
|
|
|
|
|
|
zoom_level = state.canvas.zoom_level + 1 |
|
|
|
|
|
|
|
} else if (zooming_out) { |
|
|
|
|
|
|
|
zoom_level = state.canvas.zoom_level - 1; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (zoom_level < config.min_zoom_level || zoom_level > config.max_zoom_level) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const dz = (zoom_level > 0 ? config.zoom_delta : -config.zoom_delta); |
|
|
|
|
|
|
|
state.canvas.zoom_level = zoom_level; |
|
|
|
|
|
|
|
state.canvas.target_zoom = Math.pow(1.0 + dz, Math.abs(zoom_level)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
do_draw = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (state.moving) { |
|
|
|
if (state.moving) { |
|
|
|
state.canvas.offset.x += e.movementX; |
|
|
|
state.canvas.offset.x += e.movementX; |
|
|
@ -288,7 +322,7 @@ function mousemove(e, state, context) { |
|
|
|
|
|
|
|
|
|
|
|
if (state.drawing) { |
|
|
|
if (state.drawing) { |
|
|
|
canvasp.pressure = Math.ceil(e.pressure * 255); |
|
|
|
canvasp.pressure = Math.ceil(e.pressure * 255); |
|
|
|
geometry_add_point(state, context, state.me, canvasp); |
|
|
|
geometry_add_point(state, context, state.me, canvasp, e.pointerType === "pen"); |
|
|
|
fire_event(state, predraw_event(canvasp.x, canvasp.y)); |
|
|
|
fire_event(state, predraw_event(canvasp.x, canvasp.y)); |
|
|
|
do_draw = true; |
|
|
|
do_draw = true; |
|
|
|
} |
|
|
|
} |
|
|
@ -321,6 +355,11 @@ function mouseup(e, state, context) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (state.zooming) { |
|
|
|
|
|
|
|
state.zooming = false; |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (state.moving_image) { |
|
|
|
if (state.moving_image) { |
|
|
|
schedule_draw(state, context); |
|
|
|
schedule_draw(state, context); |
|
|
|
queue_event(state, image_move_event(context.active_image, state.moving_image.x, state.moving_image.y)); |
|
|
|
queue_event(state, image_move_event(context.active_image, state.moving_image.x, state.moving_image.y)); |
|
|
@ -395,7 +434,7 @@ function update_cursor(state) { |
|
|
|
function wheel(e, state, context) { |
|
|
|
function wheel(e, state, context) { |
|
|
|
const screenp = {'x': window.devicePixelRatio * e.clientX, 'y': window.devicePixelRatio * e.clientY}; |
|
|
|
const screenp = {'x': window.devicePixelRatio * e.clientX, 'y': window.devicePixelRatio * e.clientY}; |
|
|
|
const zooming_in = e.deltaY < 0; |
|
|
|
const zooming_in = e.deltaY < 0; |
|
|
|
const zoom_level = zooming_in ? state.canvas.zoom_level + 1 : state.canvas.zoom_level - 1; |
|
|
|
const zoom_level = zooming_in ? state.canvas.zoom_level + 2 : state.canvas.zoom_level - 2; |
|
|
|
|
|
|
|
|
|
|
|
if (zoom_level < config.min_zoom_level || zoom_level > config.max_zoom_level) { |
|
|
|
if (zoom_level < config.min_zoom_level || zoom_level > config.max_zoom_level) { |
|
|
|
return; |
|
|
|
return; |
|
|
|