mirror of
https://github.com/tsl0922/EPD-nRF5.git
synced 2025-12-06 15:42:48 +08:00
update brush on dithering change
This commit is contained in:
@@ -93,9 +93,13 @@ function initPaintTools() {
|
|||||||
redrawTextElements();
|
redrawTextElements();
|
||||||
redrawLineSegments();
|
redrawLineSegments();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Update the brush color options based on dithering method
|
||||||
|
document.getElementById('dithering').addEventListener('change', updateBrushOptions);
|
||||||
|
|
||||||
// Ensure no tool is selected by default
|
// Ensure no tool is selected by default
|
||||||
updateToolUI();
|
updateToolUI();
|
||||||
|
updateBrushOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
function setActiveTool(tool, title) {
|
function setActiveTool(tool, title) {
|
||||||
@@ -108,6 +112,23 @@ function setActiveTool(tool, title) {
|
|||||||
cancelTextPlacement();
|
cancelTextPlacement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateBrushOptions() {
|
||||||
|
const dithering = document.getElementById('dithering').value;
|
||||||
|
const brushColor = document.getElementById('brush-color');
|
||||||
|
for (option of brushColor.getElementsByTagName('option')) {
|
||||||
|
if (option.value === '#FF0000') {
|
||||||
|
if (dithering.startsWith('bwr'))
|
||||||
|
option.removeAttribute('disabled');
|
||||||
|
else
|
||||||
|
option.setAttribute('disabled', 'disabled');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Revert brush color to black if red is not allowed
|
||||||
|
if (!dithering.startsWith('bwr') && brushColor.value === '#FF0000') {
|
||||||
|
brushColor.value = '#000000';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function updateToolUI() {
|
function updateToolUI() {
|
||||||
// Update UI to reflect active tool or no tool
|
// Update UI to reflect active tool or no tool
|
||||||
document.getElementById('brush-mode').classList.toggle('active', currentTool === 'brush');
|
document.getElementById('brush-mode').classList.toggle('active', currentTool === 'brush');
|
||||||
|
|||||||
Reference in New Issue
Block a user