Skip to content

Commit

Permalink
fix: after activating eraser mode, it could no longer be deactivated.
Browse files Browse the repository at this point in the history
  • Loading branch information
jannickheisch committed Jan 31, 2024
1 parent 51c4671 commit 965a533
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions android/tinySSB/app/src/main/assets/web/sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ function chat_openSketch() {
var lastX = 0;
var lastY = 0;
var colChoice = true;
var currentColor = '#000000'

canvas.addEventListener('touchstart', startDrawing);
canvas.addEventListener('touchmove', draw);
Expand Down Expand Up @@ -190,6 +191,7 @@ function chat_openSketch() {
function setStrokeColor(color) {
ctx.globalCompositeOperation = 'source-over';
strokeColor = color;
currentColor = color
}

//function to either add or remove the color Palette depending on if it exists
Expand All @@ -213,13 +215,14 @@ function chat_openSketch() {

//eraser function
function toggleEraser() {
ctx.globalCompositeOperation = 'destination-out';
ctx.strokeStyle = "rgba(255,255,255,1)";
isEraserEnabled = !isEraserEnabled;
if (isEraserEnabled) {
ctx.globalCompositeOperation = 'destination-out';
ctx.strokeStyle = "rgba(255,255,255,1)";
ctx.lineWidth = 30;
eraserSign.style.border = '1px solid red';
} else {
setStrokeColor(currentColor)
ctx.lineWidth = currentWidth;
eraserSign.style.border = '';
}
Expand Down

0 comments on commit 965a533

Please sign in to comment.