Skip to content

Commit

Permalink
add invert button, flat causes circle to be fat
Browse files Browse the repository at this point in the history
  • Loading branch information
phentos committed Jun 27, 2023
1 parent ab51505 commit 4a32fd9
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
6 changes: 6 additions & 0 deletions images/yang-yin.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions images/yin-yang.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<fieldset>
<div>
<img class="block" id="floppy" src="images/floppy.svg" width="75px" height="50px">
<img class="block" id="invert" src="images/yin-yang.svg" width="75px" height="50px">

<br>

Expand Down
14 changes: 13 additions & 1 deletion touch.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
const debug = true;

const FG_COLOR = "#000";
const BG_COLOR = "#666";
const COLOR_STATE_SYMBOLS = {
[FG_COLOR]:'images/yin-yang.svg',
[BG_COLOR]:'images/yang-yin.svg'
}

const touchEventHandlers = [
["touchstart", handleStart],
["touchend", handleEnd],
Expand All @@ -16,7 +23,7 @@ const penModeSelections = [

const touchHistory = {};

let penColor = "black";
let penColor = FG_COLOR;
let penSize = 4;
let penMode = dot;

Expand All @@ -36,6 +43,11 @@ function activateUIHandlers() {
updatePenSize(event.target.value);
});

document.querySelector("#invert").addEventListener('click', () => {
penColor = (penColor === BG_COLOR) ? FG_COLOR : BG_COLOR;
document.querySelector('#invert').src = COLOR_STATE_SYMBOLS[penColor];
})

penModeSelections.forEach(([elementId, penFunction, defaultPenSize]) => {
document.querySelector(elementId).addEventListener('change', (event) => {
event.preventDefault();
Expand Down

0 comments on commit 4a32fd9

Please sign in to comment.