From d77bbfe8ca04257a16229d23ab69542bb5bcd0bf Mon Sep 17 00:00:00 2001 From: Dev 1 Date: Tue, 5 Sep 2023 16:24:27 +0530 Subject: [PATCH] work on tracing game --- src/layouts/Layout.astro | 4 +- src/pages/drawing/index.astro | 38 +++----- src/pages/tracing/index.astro | 167 ++++++++++++++++++++-------------- 3 files changed, 114 insertions(+), 95 deletions(-) diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index b2b8504..ffc6738 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -33,7 +33,7 @@ const { title } = Astro.props; font-family: Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace; } */ - body{ + /* body{ font-family: quicksand; animation: fadeInAnimation ease 6s; animation-iteration-count: 1; @@ -46,5 +46,5 @@ const { title } = Astro.props; 100% { opacity: 1; } - } + } */ diff --git a/src/pages/drawing/index.astro b/src/pages/drawing/index.astro index 31456c6..de261c2 100644 --- a/src/pages/drawing/index.astro +++ b/src/pages/drawing/index.astro @@ -89,22 +89,16 @@ import Layout from '../../layouts/Layout.astro'; colorContainer.style.top = '10%'; colorContainer.style.left = '20px'; colorContainer.style.display = 'flex'; // Display color picker and buttons horizontally + // Create the color picker const colorPicker = document.createElement('input'); colorPicker.type = 'color'; colorPicker.value = selectedColor; colorPicker.className = 'color-picker'; - colorPicker.style.marginTop = '-0px'; - colorPicker.style.marginRight = '15px'; - colorPicker.style.padding = '1px 1px'; - colorPicker.style.outline = 'none'; - colorPicker.style.width = '46px'; - colorPicker.style.height = '46px'; - colorPicker.style.border = '3px solid #05b3a4'; - colorPicker.style.backgroundColor = '#05b3a4'; - colorPicker.style.borderRadius = '50%'; - colorPicker.style.boxShadow = '5px 10px 30px #7c4c2390'; - + colorPicker.style.marginTop = '-5px'; + colorPicker.style.marginRight = '5px'; + colorPicker.style.width = '45px'; + colorPicker.style.height = '48px'; colorPicker.addEventListener('input', (event) => { if (!isErasing) { @@ -116,8 +110,8 @@ import Layout from '../../layouts/Layout.astro'; colorContainer.appendChild(colorPicker); const colors = ['#ff0000', '#00ff00', '#0000ff', '#ffff00', '#ff00ff', '#00ffff']; - const buttonSize = 50; - const buttonSpacing = 15; + const buttonSize = 40; + const buttonSpacing = 10; // Create a container div for the color buttons const colorButtonsContainer = document.createElement('div'); @@ -136,15 +130,13 @@ import Layout from '../../layouts/Layout.astro'; button.style.backgroundColor = color; button.style.width = `${buttonSize}px`; button.style.height = `${buttonSize}px`; - button.style.border = '3px solid #05b3a4'; - button.style.boxShadow = '5px 10px 30px #7c4c2390'; - button.style.borderRadius = '50%' + button.style.border = 'none'; button.style.marginRight = `${buttonSpacing}px`; button.addEventListener('click', () => { // Remove the mark from the previously selected button, if any if (selectedButton) { - // Remove the border + selectedButton.style.border = 'none'; // Remove the border } // Set the new selected color selectedColor = color; @@ -168,24 +160,21 @@ import Layout from '../../layouts/Layout.astro'; // Create a container div for both buttons const buttonsContainer = document.createElement('div'); buttonsContainer.style.position = 'absolute'; - buttonsContainer.style.left = '20px'; - buttonsContainer.style.top = '17%'; - // buttonsContainer.style.left = `${window.innerWidth * 0.03}px`; // Position 5% from the left edge + buttonsContainer.style.top = '15%'; + buttonsContainer.style.left = `${window.innerWidth * 0.03}px`; // Position 5% from the left edge document.body.appendChild(buttonsContainer); // Create the Clear button const clearButton = document.createElement('button'); clearButton.innerHTML =''; - clearButton.style.border = '3px solid blue'; // clearButton.textContent = 'Clear'; clearButton.style.color = 'blue'; // clearButton.style.color = 'white'; - clearButton.style.marginRight = '10px'; clearButton.style.padding = '5px 10px'; clearButton.style.fontSize = '16px'; clearButton.style.fontWeight = 'bold'; clearButton.style.borderRadius = '50%'; - clearButton.style.boxShadow = '5px 10px 30px #7c4c2390'; + clearButton.style.boxShadow = '5px 20px 30px #7c4c2390'; clearButton.addEventListener('click', () => { clearDrawing(); }); @@ -195,9 +184,7 @@ import Layout from '../../layouts/Layout.astro'; // eraserButton.textContent = 'Eraser'; eraserButton.innerHTML = ''; eraserButton.style.color = '#7c4c23'; - eraserButton.style.border = '3px solid #7c4c23'; // eraserButton.style.color = 'white'; - eraserButton.style.marginRight = '15px'; eraserButton.style.padding = '5px 5px'; eraserButton.style.fontSize = '16px'; eraserButton.style.fontWeight = 'bold'; @@ -232,7 +219,6 @@ import Layout from '../../layouts/Layout.astro'; slider.max = '80'; slider.value = brushSize.toString(); slider.className = 'slider'; - // slider.style.width = `${window.innerWidth / 2}px`; slider.addEventListener('input', (event) => { brushSize = parseInt(event.target.value); diff --git a/src/pages/tracing/index.astro b/src/pages/tracing/index.astro index 0ec3ccd..af240e1 100644 --- a/src/pages/tracing/index.astro +++ b/src/pages/tracing/index.astro @@ -10,80 +10,113 @@ import Layout from '../../layouts/Layout.astro';