From cd66708c4c67d986af162cc4ae59fb3e04f9b2d9 Mon Sep 17 00:00:00 2001 From: Andrew Michael McNutt Date: Sat, 24 Feb 2024 06:58:09 -0700 Subject: [PATCH] make distributes more understandable --- src/controls/DistributePoints.svelte | 22 +++++++++++++--------- src/scatterplot/ColorScatterPlot.svelte | 20 ++++++++++++++------ 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/src/controls/DistributePoints.svelte b/src/controls/DistributePoints.svelte index 70783911..47a5bda9 100644 --- a/src/controls/DistributePoints.svelte +++ b/src/controls/DistributePoints.svelte @@ -11,11 +11,14 @@ $: config = colorPickerConfig[colorSpace]; $: zName = colorPickerConfig[colorSpace].zChannel; - type Direction = "horizontal" | "vertical" | "in z space"; - function distributePoints(direction: Direction) { + interface Direction { + direction: "horizontal" | "vertical" | "in z space"; + name: string; + } + function distributePoints(dir: Direction) { let sortedIndexes = focusedColors.sort((a, b) => { const modeToIdx = { horizontal: 1, vertical: 2, "in z space": 0 }; - const idx = modeToIdx[direction] || 0; + const idx = modeToIdx[dir.direction] || 0; const pointA = colors[a].toChannels()[idx]; const pointB = colors[b].toChannels()[idx]; return pointA - pointB; @@ -33,9 +36,9 @@ const xIdx = config.xChannelIndex; const yIdx = config.yChannelIndex; const zIdx = config.zChannelIndex; - if (direction === "horizontal") { + if (dir.direction === "horizontal") { newPoint[xIdx] = minPoint[xIdx] * (1 - t) + maxPoint[xIdx] * t; - } else if (direction === "vertical") { + } else if (dir.direction === "vertical") { newPoint[yIdx] = minPoint[yIdx] * (1 - t) + maxPoint[yIdx] * t; } else { newPoint[zIdx] = minPoint[zIdx] * (1 - t) + maxPoint[zIdx] * t; @@ -53,10 +56,11 @@ colorStore.setCurrentPalColors(newColors); } + $: isPolar = config.isPolar; $: directions = [ - "horizontal", - "vertical", - `in ${zName} space`, + { direction: "horizontal", name: isPolar ? "radial" : "horizontal" }, + { direction: "vertical", name: isPolar ? "angle" : "vertical" }, + { direction: "in z space", name: `in ${zName.toUpperCase()} space` }, ] as Direction[]; @@ -66,7 +70,7 @@
{#each directions as direction} {/each}
diff --git a/src/scatterplot/ColorScatterPlot.svelte b/src/scatterplot/ColorScatterPlot.svelte index 66f37e58..a886a81c 100644 --- a/src/scatterplot/ColorScatterPlot.svelte +++ b/src/scatterplot/ColorScatterPlot.svelte @@ -198,7 +198,7 @@ let selectionUpdate = (isZ: boolean) => (e: any) => { // console.log("selection update"); const { x, y } = toXY(e); - selectionMouseCurrent = { x, y }; + selectionMouseCurrent = { x: x + 10, y: y + 20 }; }; let selectionEnd = (isZ: boolean) => (e: any) => { interactionMode = "idle"; @@ -304,12 +304,19 @@
-
- + {}} + > {#if config.isPolar} @@ -590,7 +597,8 @@
- {#if $configStore.showGamutMarkers} ⨂indicates out of gamut value{:else} {/if} + {#if $configStore.showGamutMarkers} + ⨂indicates out of gamut value{:else} {/if}