CSS rule cleaning; fixed canvas clear issues; added rotation global

This commit is contained in:
2026-11-01 01:37:33 -05:00
parent 9315c903a8
commit b81851f07e
4 changed files with 13 additions and 9 deletions
@@ -4,8 +4,7 @@ const resetCanvasState = () => {
clearCanvas();
}
const resetRotation = () => { Painter.rotation = 0; }
const clearCanvas = () => { Painter.canvasContext.clearRect(0, 0, canvas.width, canvas.height); }
const resetRotation = () => { Painter.rotation = ROTATION; }
const resetCanvasBrush = () => {
setDefaultBrushSize();
@@ -13,6 +12,11 @@ const resetCanvasBrush = () => {
setBrushToCenter();
}
const clearCanvas = () => {
Painter.canvasContext.clearRect(0, 0, canvas.width, canvas.height);
Painter.canvasContext.beginPath();
}
const setDefaultBrushSize = () => {
Painter.brushSize = BRUSH_SIZE;
Painter.canvasContext.lineWidth = BRUSH_SIZE;
+1 -1
View File
@@ -34,7 +34,7 @@ window.onload = (eve) => {
clearBttn.onclick = (eve) => {
clearScriptNode();
clearCanvas();
resetCanvasState();
}
saveBttn.onclick = (eve) => { saveScript(); }
+2 -1
View File
@@ -14,13 +14,14 @@ const ScriptElms = {
const BRUSH_SIZE = 2;
const BRUSH_COLOR = "#000000";
const ROTATION = 0;
let Painter = {
canvas: null,
canvasContext: null,
brushSize: BRUSH_SIZE,
brushColor: BRUSH_COLOR,
rotation: 0,
rotation: ROTATION,
x1: 0,
y1: 0,
isBrushLifted: false