mirror of
https://github.com/tsl0922/EPD-nRF5.git
synced 2025-12-06 15:42:48 +08:00
update paint support
This commit is contained in:
@@ -164,8 +164,8 @@
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript" src="js/dithering.js?v=20250519"></script>
|
||||
<script type="text/javascript" src="js/main.js?v=20250519"></script>
|
||||
<script type="text/javascript" src="js/paint.js?v=20250519"></script>
|
||||
<script type="text/javascript" src="js/main.js?v=20250519"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -378,6 +378,8 @@ function clearCanvas() {
|
||||
if (confirm('清除画布已有内容?')) {
|
||||
ctx.fillStyle = 'white';
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
textElements = []; // Clear stored text positions
|
||||
lineSegments = []; // Clear stored line segments
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -393,6 +395,10 @@ function convertDithering() {
|
||||
const threshold = document.getElementById('threshold').value;
|
||||
dithering(ctx, canvas.width, canvas.height, parseInt(threshold), mode);
|
||||
}
|
||||
|
||||
// Redraw text and lines
|
||||
redrawTextElements();
|
||||
redrawLineSegments();
|
||||
}
|
||||
|
||||
function filterDitheringOptions() {
|
||||
@@ -442,6 +448,7 @@ document.body.onload = () => {
|
||||
ctx.fillStyle = 'white';
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
initPaintTools();
|
||||
updateButtonStatus();
|
||||
checkDebugMode();
|
||||
}
|
||||
@@ -74,26 +74,6 @@ function initPaintTools() {
|
||||
|
||||
setupCanvasForPainting();
|
||||
|
||||
// Override the existing clear_canvas function to clear our text positions too
|
||||
const originalClearCanvas = window.clear_canvas;
|
||||
window.clear_canvas = function() {
|
||||
if(originalClearCanvas()) {
|
||||
textElements = []; // Clear stored text positions
|
||||
lineSegments = []; // Clear stored line segments
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
// Override the existing convert_dithering function to preserve text and lines
|
||||
const originalConvertDithering = window.convert_dithering;
|
||||
window.convert_dithering = function() {
|
||||
originalConvertDithering();
|
||||
// Redraw text and lines after dithering
|
||||
redrawTextElements();
|
||||
redrawLineSegments();
|
||||
};
|
||||
|
||||
// Update the brush color options based on dithering method
|
||||
document.getElementById('dithering').addEventListener('change', updateBrushOptions);
|
||||
|
||||
@@ -451,8 +431,3 @@ function redrawLineSegments() {
|
||||
ctx.stroke();
|
||||
});
|
||||
}
|
||||
|
||||
// Initialize paint functionality when the page loads
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
setTimeout(initPaintTools, 500); // Delay to ensure canvas is initialized
|
||||
});
|
||||
Reference in New Issue
Block a user