Skip to content

Commit

Permalink
improve naive clip to gamut
Browse files Browse the repository at this point in the history
  • Loading branch information
mcnuttandrew committed Jan 17, 2024
1 parent 42e0624 commit 4c8fdf7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/components/ColorScatterPlot.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@
class="pointer-events-none"
/>
{/if}
{#if pickedColors.length}
{#if pickedColors.length && focusedColors.length > 1}
<rect
x={5}
y={pos.zPos - 5}
Expand All @@ -515,7 +515,7 @@
-moz-transition: r 0.2s ease-in-out;
}
svg {
/* svg {
overflow: visible;
}
} */
</style>
2 changes: 1 addition & 1 deletion src/components/ColorScatterPlotXYGuides.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
centerTop: {
x: (xScale.range()[1] - xScale.range()[0]) / 2,
y: yScale.range()[0],
labelAdjust: { x: 0, y: -5 },
labelAdjust: { x: 0, y: -3 },
anchor: "middle",
label: `${config.yChannel}: ${axisFormatter(yScale.domain()[0])}`,
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/ColorScatterPlotZGuide.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
$: zPoints = {
top: {
y: zScale.range()[0] + 8,
y: zScale.range()[0] + 15,
label: `${config.zChannel.toUpperCase()}: ${zScale
.domain()[0]
.toFixed(1)}`,
Expand Down
11 changes: 10 additions & 1 deletion src/content-modules/contextual-tools/ClipToGamut.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,19 @@
$: colors = $colorStore.currentPal.colors;
const clamp = (x: number, min: number, max: number) =>
Math.min(Math.max(x, min), max);
function clipToGamut() {
const newColors = colors.map((x) => {
if (x.inGamut()) {
return x;
const channels = Object.entries(x.domains).map(([key, domain]) => {
const [min, max] = domain.sort();
return clamp(x.channels[key], min, max);
});
return x.fromChannels(channels as [number, number, number]);
// return x;
} else {
const newChannels = x
.toColorIO()
Expand Down

0 comments on commit 4c8fdf7

Please sign in to comment.