Skip to content

Commit

Permalink
Better complement.
Browse files Browse the repository at this point in the history
  • Loading branch information
amyjko committed Jul 9, 2024
1 parent d302eb1 commit 7356030
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/components/app/Page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
: '';
document.body.style.color = $fullscreen.on
? $fullscreen.background instanceof Color
? $fullscreen.background.complement().toCSS()
? $fullscreen.background.contrasting().toCSS()
: ''
: '';
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/output/StageView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@
style:background={background ? stage.back.toCSS() : null}
style:color={getColorCSS(stage.getFirstRestPose(), stage.pose)}
style:opacity={getOpacityCSS(stage.getFirstRestPose(), stage.pose)}
style:--grid-color={stage.back.complement().toCSS()}
style:--grid-color={stage.back.contrasting().toCSS()}
bind:this={view}
>
<!-- Render the stage -->
Expand Down
2 changes: 1 addition & 1 deletion src/components/project/TileView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
onMount(() => (mounted = true));
$: foreground =
background instanceof Color ? background.complement().toCSS() : null;
background instanceof Color ? background.contrasting().toCSS() : null;
const dispatch = createEventDispatcher();
Expand Down
1 change: 1 addition & 0 deletions src/components/widgets/Button.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
}
.background {
color: var(--wordplay-foreground);
background: var(--wordplay-alternating-color);
}
Expand Down
8 changes: 4 additions & 4 deletions src/output/Color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ export default class Color extends Valued {
this.hue = h;
}

complement() {
contrasting() {
return new Color(
this.value,
new Decimal(1).sub(this.lightness),
this.chroma,
new Decimal(180).add(this.hue),
new Decimal(this.lightness.greaterThan(0.5) ? 0 : 1),
new Decimal(100),
new Decimal(0),
);
}

Expand Down

0 comments on commit 7356030

Please sign in to comment.