|
|
|
@ -107,21 +107,25 @@ function zenmode() {
@@ -107,21 +107,25 @@ function zenmode() {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function enter_picker_mode(state, context) { |
|
|
|
|
document.querySelector('canvas').classList.add('picker'); |
|
|
|
|
document.querySelector('.picker-preview-outer').classList.remove('dhide'); |
|
|
|
|
document.querySelector('.brush-dom').classList.add('dhide'); |
|
|
|
|
|
|
|
|
|
state.colorpicking = true; |
|
|
|
|
if (state.tools.active === 'pencil') { // or other drawing tools
|
|
|
|
|
document.querySelector('canvas').classList.add('picker'); |
|
|
|
|
document.querySelector('.picker-preview-outer').classList.remove('dhide'); |
|
|
|
|
document.querySelector('.brush-dom').classList.add('dhide'); |
|
|
|
|
|
|
|
|
|
state.colorpicking = true; |
|
|
|
|
|
|
|
|
|
const canvasp = screen_to_canvas(state, state.cursor); |
|
|
|
|
update_color_picker_color(state, context, canvasp); |
|
|
|
|
const canvasp = screen_to_canvas(state, state.cursor); |
|
|
|
|
update_color_picker_color(state, context, canvasp); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function exit_picker_mode(state) { |
|
|
|
|
document.querySelector('canvas').classList.remove('picker'); |
|
|
|
|
document.querySelector('.picker-preview-outer').classList.add('dhide'); |
|
|
|
|
document.querySelector('.brush-dom').classList.remove('dhide'); |
|
|
|
|
state.colorpicking = false; |
|
|
|
|
if (state.colorpicking) { |
|
|
|
|
document.querySelector('canvas').classList.remove('picker'); |
|
|
|
|
document.querySelector('.picker-preview-outer').classList.add('dhide'); |
|
|
|
|
document.querySelector('.brush-dom').classList.remove('dhide'); |
|
|
|
|
state.colorpicking = false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async function paste(e, state, context) { |
|
|
|
@ -160,7 +164,7 @@ function keyup(e, state, context) {
@@ -160,7 +164,7 @@ function keyup(e, state, context) {
|
|
|
|
|
state.moving = false; |
|
|
|
|
context.canvas.classList.remove('movemode'); |
|
|
|
|
} else if (e.code === 'ControlLeft' || e.code === 'ControlRight') { |
|
|
|
|
exit_picker_mode(state); |
|
|
|
|
exit_picker_mode(state);exit_picker_mode |
|
|
|
|
} else if (e.code === 'KeyZ') { |
|
|
|
|
state.zoomdown = false; |
|
|
|
|
} |
|
|
|
@ -170,21 +174,6 @@ function mousedown(e, state, context) {
@@ -170,21 +174,6 @@ function mousedown(e, state, context) {
|
|
|
|
|
const screenp = {'x': window.devicePixelRatio * e.clientX, 'y': window.devicePixelRatio * e.clientY}; |
|
|
|
|
const canvasp = screen_to_canvas(state, screenp); |
|
|
|
|
|
|
|
|
|
if (e.button === 2) { |
|
|
|
|
// Right click on image to select it
|
|
|
|
|
const image_event = image_at(state, canvasp.x, canvasp.y); |
|
|
|
|
|
|
|
|
|
if (image_event) { |
|
|
|
|
context.active_image = image_event.image_id; |
|
|
|
|
} else { |
|
|
|
|
context.active_image = null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
schedule_draw(state, context); |
|
|
|
|
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (e.button !== 0 && e.button !== 1) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
@ -203,15 +192,6 @@ function mousedown(e, state, context) {
@@ -203,15 +192,6 @@ function mousedown(e, state, context) {
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (context.active_image) { |
|
|
|
|
// Move selected image with left click
|
|
|
|
|
const image_event = image_at(state, canvasp.x, canvasp.y); |
|
|
|
|
if (image_event && image_event.image_id === context.active_image) { |
|
|
|
|
state.moving_image = image_event; |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (state.spacedown || e.button === 1) { |
|
|
|
|
state.moving = true; |
|
|
|
|
context.canvas.classList.add('moving'); |
|
|
|
@ -236,6 +216,16 @@ function mousedown(e, state, context) {
@@ -236,6 +216,16 @@ function mousedown(e, state, context) {
|
|
|
|
|
|
|
|
|
|
} else if (state.tools.active === 'eraser') { |
|
|
|
|
state.erasing = true; |
|
|
|
|
} else if (state.tools.active === 'pointer') { |
|
|
|
|
const image_event = image_at(state, canvasp.x, canvasp.y); |
|
|
|
|
|
|
|
|
|
if (image_event) { |
|
|
|
|
context.active_image = image_event.image_id; |
|
|
|
|
} else { |
|
|
|
|
context.active_image = null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
schedule_draw(state, context); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -412,7 +402,7 @@ function mouseleave(e, state, context) {
@@ -412,7 +402,7 @@ function mouseleave(e, state, context) {
|
|
|
|
|
context.canvas.classList.remove('movemode'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
exit_picker_mode(state); |
|
|
|
|
//exit_picker_mode(state);
|
|
|
|
|
// something else?
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|