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.
82 lines
1.5 KiB
82 lines
1.5 KiB
2 years ago
|
'use strict';
|
||
|
|
||
|
let GRID_HOTKEY;
|
||
|
|
||
|
p.keyPressed = () => {
|
||
|
if (givesFeedback)
|
||
|
return;
|
||
|
if (p.keyCode === GRID_HOTKEY && drawer)
|
||
|
drawer.gridActive = !drawer.gridActive;
|
||
|
}
|
||
|
|
||
|
p.keyTyped = () => {
|
||
|
if (givesFeedback)
|
||
|
return;
|
||
|
if (settingHotkey){
|
||
|
GRID_HOTKEY = p.keyCode;
|
||
|
//p.storeItem('gridHotkey', GRID_HOTKEY);
|
||
|
$('#grid_hotkey').html(String.fromCharCode(p.keyCode));
|
||
|
settingHotkey = false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
p.mouseMoved = () => {
|
||
|
if (givesFeedback)
|
||
|
return;
|
||
|
if (drawer)
|
||
|
drawer.onMouseMoved();
|
||
|
}
|
||
|
|
||
|
p.mouseDragged = () => {
|
||
|
if (givesFeedback)
|
||
|
return;
|
||
|
if (drawer)
|
||
|
if (!drawer.hasDrawnAllLines || !drawer.hasFilledAllPixels)
|
||
|
return;
|
||
|
if (colorPicker)
|
||
|
colorPicker.mouseDragged();
|
||
|
if (drawer)
|
||
|
drawer.onMouseDragged();
|
||
|
}
|
||
|
|
||
|
p.mousePressed = () => {
|
||
|
if (drawer)
|
||
|
if (!drawer.hasDrawnAllLines || !drawer.hasFilledAllPixels)
|
||
|
return;
|
||
|
if (givesFeedback)
|
||
|
return;
|
||
|
if (drawer)
|
||
|
drawer.onMouseDown();
|
||
|
if (colorPicker)
|
||
|
colorPicker.mousePressed();
|
||
|
}
|
||
|
|
||
|
p.mouseReleased = () => {
|
||
|
if (drawer)
|
||
|
if (!drawer.hasDrawnAllLines || !drawer.hasFilledAllPixels)
|
||
|
return;
|
||
|
if (givesFeedback)
|
||
|
return;
|
||
|
if (drawer)
|
||
|
drawer.onMouseUp();
|
||
|
if (colorPicker)
|
||
|
colorPicker.mouseReleased();
|
||
|
}
|
||
|
|
||
|
p.mouseWheel = (e) => {
|
||
|
if (drawer)
|
||
|
if (drawer.hasDrawnAllLines && drawer.hasFilledAllPixels)
|
||
|
drawer.zoom(e.delta);
|
||
|
e.preventDefault();
|
||
|
}
|
||
|
|
||
|
window.onresize = () => {
|
||
|
p.resizeCanvas($("#canvas-holder").width(), $("#canvas-holder").height());
|
||
|
}
|
||
|
|
||
|
let settingHotkey = false;
|
||
|
function setGridHotkey(dom){
|
||
|
$(dom).blur();
|
||
|
settingHotkey = true;
|
||
|
}
|