diff --git a/frontend/src/App.svelte b/frontend/src/App.svelte index 7d8b5f6..f073fea 100644 --- a/frontend/src/App.svelte +++ b/frontend/src/App.svelte @@ -24,6 +24,7 @@ import { CopyPaste } from './types/copypaste' import type { PixelPosition } from './types/shapes.js'; import ColorSelector from './components/ColorSelector.svelte'; + import ColorIndex from './components/ColorIndex.svelte'; let theme: 'white'|'g10'|'g80'|'g90'|'g100' = 'g90' @@ -37,6 +38,13 @@ $: primaryColor = palette?.[primaryColorIndex] $: secondaryColor = palette?.[secondaryColorIndex] + let red: number = 0 + let green: number = 0 + let blue: number = 0 + let alpha: number = 0 + + let refreshPalette = {} + // Oh no, what are you doing, step palette~ function stepPalette(step: number, primary: boolean) { if (primary) { @@ -139,6 +147,18 @@ focusedFileIndex = Math.min(files.length-1, focusedFileIndex) } } + + function handlePaletteSelect(event: CustomEvent) { + let index = event.detail.index + + if (index < 0 || index >= focusedFile.canvas.palette.length) return + + let entry = focusedFile.canvas.palette[index] + red = entry & 0xFF + green = (entry >> 8) & 0xFF + blue = (entry >> 16) & 0xFF + alpha = (entry >> 24) & 0xFF + } @@ -169,8 +189,11 @@
- - + +
+ + refreshPalette={}} /> +
diff --git a/frontend/src/components/ColorIndex.svelte b/frontend/src/components/ColorIndex.svelte new file mode 100644 index 0000000..96b8b67 --- /dev/null +++ b/frontend/src/components/ColorIndex.svelte @@ -0,0 +1,51 @@ + + +
+
+
{index}
+
+ + +
+ + \ No newline at end of file diff --git a/frontend/src/components/ColorSelector.svelte b/frontend/src/components/ColorSelector.svelte index 987b754..4951c12 100644 --- a/frontend/src/components/ColorSelector.svelte +++ b/frontend/src/components/ColorSelector.svelte @@ -1,28 +1,161 @@
-
-
+
+
+
+
+
+
+
+
-
+
+
-
+
-
+
+
@@ -33,11 +166,96 @@ display: flex; } .hsv { + position: relative; min-height: 9em; width: 100%; - border: 1px solid red; + overflow: hidden; + user-select: none; } - .hue { + .hsv_hue { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + } + .hsv_saturation { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + background-image: + linear-gradient(to right, + rgba(255, 255, 255, 255) 0%, + rgba(255, 255, 255, 0) 100%) + ; + } + .hsv_value { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + background-image: + linear-gradient(to bottom, + transparent 0%, + rgb(0, 0, 0) 100%) + ; + } + .hsv_cursor { + position: absolute; + width: 100%; + height: 100%; + pointer-events: none; + } + .hsv_cursor-left { + position: absolute; + left: -100%; + top: -2px; + margin-left: -1px; + width: 100%; + height: 3px; + background: black; + border: 1px solid rgba(255,255,255,0.5); + border-right: 0; + border-left: 0; + } + .hsv_cursor-right { + position: absolute; + left: 0; + top: -2px; + width: 100%; + height: 3px; + background: black; + border: 1px solid rgba(255,255,255,0.5); + border-right: 0; + border-left: 0; + } + .hsv_cursor-bottom { + position: absolute; + left: -2px; + top: 0; + width: 3px; + height: 100%; + background: black; + border: 1px solid rgba(255,255,255,0.5); + border-bottom: 0; + border-top: 0; + } + .hsv_cursor-top { + position: absolute; + left: -2px; + top: -100%; + margin-top: -1px; + width: 3px; + height: 100%; + background: black; + border: 1px solid rgba(255,255,255,0.5); + border-bottom: 0; + border-top: 0; + } + .hue { background-image: linear-gradient(to left, #ff0000, #ff0080, #ff00ff, #8000ff, @@ -49,10 +267,6 @@ ); } .alpha { - background-image: linear-gradient(to right, - transparent 0%, - rgba(255, 0, 0, 1) 100% - ); z-index: 0; } .checkerboard { @@ -68,4 +282,21 @@ background-size: 10px 10px; background-position: 0 0, 0 5px, 5px -5px, -5px 0px; } + .slider { + position: relative; + user-select: none; + overflow: hidden; + } + .cursor { + position: absolute; + top: 0; + left: 0; + width: 4px; + height: 100%; + border: 1px solid black; + border-top: 0; + border-bottom: 0; + margin-left: -2px; + z-index: 1; + } \ No newline at end of file diff --git a/frontend/src/sections/Palette.svelte b/frontend/src/sections/Palette.svelte index 7911af2..843a34b 100644 --- a/frontend/src/sections/Palette.svelte +++ b/frontend/src/sections/Palette.svelte @@ -1,19 +1,50 @@