|
|
|
@ -22,9 +22,30 @@ function switch_color(state, item) {
@@ -22,9 +22,30 @@ function switch_color(state, item) {
|
|
|
|
|
state.colors.active_element.classList.add('active'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function show_stroke_preview(state, size) { |
|
|
|
|
const preview = document.querySelector('#stroke-preview'); |
|
|
|
|
|
|
|
|
|
preview.style.width = size * state.canvas.zoom + 'px'; |
|
|
|
|
preview.style.height = size * state.canvas.zoom + 'px'; |
|
|
|
|
preview.style.background = color_from_u32(state.colors.active); |
|
|
|
|
|
|
|
|
|
preview.classList.remove('dhide'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function hide_stroke_preview() { |
|
|
|
|
document.querySelector('#stroke-preview').classList.add('dhide'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function switch_stroke_width(e, state) { |
|
|
|
|
const value = e.target.value; |
|
|
|
|
state.stroke_width = value; |
|
|
|
|
show_stroke_preview(state, value); |
|
|
|
|
|
|
|
|
|
if (state.hide_preview) { |
|
|
|
|
clearTimeout(state.hide_preview); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
state.hide_preview = setTimeout(hide_stroke_preview, config.brush_preview_timeout); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function init_tools(state) { |
|
|
|
@ -38,7 +59,10 @@ function init_tools(state) {
@@ -38,7 +59,10 @@ function init_tools(state) {
|
|
|
|
|
switch_tool(state, document.querySelector('.tool[data-tool="pencil"]')); |
|
|
|
|
switch_color(state, document.querySelector('.color[data-color="000000"]')); |
|
|
|
|
|
|
|
|
|
document.querySelector('#stroke-width').value = state.stroke_width; |
|
|
|
|
document.querySelector('#stroke-width').addEventListener('input', (e) => switch_stroke_width(e, state)); |
|
|
|
|
const slider = document.querySelector('#stroke-width'); |
|
|
|
|
|
|
|
|
|
slider.value = state.stroke_width; |
|
|
|
|
slider.addEventListener('input', (e) => switch_stroke_width(e, state)); |
|
|
|
|
|
|
|
|
|
document.querySelector('.phone-extra-controls').addEventListener('click', zenmode); |
|
|
|
|
} |