Clean up code
This commit is contained in:
parent
087e0d7fd1
commit
69bbf7b64f
1 changed files with 6 additions and 5 deletions
11
script.js
11
script.js
|
|
@ -6,8 +6,8 @@ const buttons = document.querySelectorAll(".pen");
|
||||||
const colorPicker = document.querySelector("#custom-color");
|
const colorPicker = document.querySelector("#custom-color");
|
||||||
const reset = document.querySelector("#reset");
|
const reset = document.querySelector("#reset");
|
||||||
const backColorPicker = document.querySelector("#back-col-picker")
|
const backColorPicker = document.querySelector("#back-col-picker")
|
||||||
let colorValue = "black";
|
let colorValue;
|
||||||
let numGrid = gridSlider.value;
|
let numGrid; //= gridSlider.value;
|
||||||
let sliderLabel = document.querySelector("#sliderLabel");
|
let sliderLabel = document.querySelector("#sliderLabel");
|
||||||
|
|
||||||
//the next few variables are set to be used to test if
|
//the next few variables are set to be used to test if
|
||||||
|
|
@ -22,7 +22,7 @@ let isWhite;
|
||||||
let isErase;
|
let isErase;
|
||||||
|
|
||||||
|
|
||||||
createGrid();
|
getGridDimensions();
|
||||||
|
|
||||||
buttons.forEach((button) => {
|
buttons.forEach((button) => {
|
||||||
button.addEventListener ("click", changeColor);
|
button.addEventListener ("click", changeColor);
|
||||||
|
|
@ -39,6 +39,7 @@ function pickBackground() {
|
||||||
|
|
||||||
|
|
||||||
function createGrid() {
|
function createGrid() {
|
||||||
|
numGrid = gridSlider.value
|
||||||
const gridArea = numGrid ** 2;
|
const gridArea = numGrid ** 2;
|
||||||
const gridWidth = 100 / numGrid;
|
const gridWidth = 100 / numGrid;
|
||||||
|
|
||||||
|
|
@ -64,12 +65,12 @@ function createGrid() {
|
||||||
|
|
||||||
|
|
||||||
function getGridDimensions() {
|
function getGridDimensions() {
|
||||||
//gridSlider.value = 16;
|
gridSlider.defaultValue = 16;
|
||||||
container.style.backgroundColor = "#ffffff";
|
container.style.backgroundColor = "#ffffff";
|
||||||
backColorPicker.value = "#ffffff";
|
backColorPicker.value = "#ffffff";
|
||||||
colorPicker.value = "#000000";
|
colorPicker.value = "#000000";
|
||||||
|
colorValue = "black";
|
||||||
|
|
||||||
numGrid = gridSlider.value;
|
|
||||||
while (container.firstChild) {
|
while (container.firstChild) {
|
||||||
container.removeChild(container.lastChild);
|
container.removeChild(container.lastChild);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue