@@ -21,7 +21,11 @@ import {
2121 DIVERGING_PALETTES ,
2222} from '@arnog/colors' ;
2323import type { OklchColor , RgbColor } from '@arnog/colors' ;
24- import { isFunction , isNumber , isString } from '../boxed-expression/type-guards' ;
24+ import {
25+ isFunction ,
26+ isNumber ,
27+ isString ,
28+ } from '../boxed-expression/type-guards' ;
2529
2630/**
2731 * Canonicalize an alpha value. Returns `undefined` for undefined, non-finite,
@@ -92,7 +96,10 @@ function samplePalette(ce: any, palette: readonly string[], t: number): any {
9296 if ( frac < 1e-9 ) return colorNumberToOklch ( ce , parseColor ( palette [ i ] ) ) ;
9397
9498 // interpolateOklch returns an RgbColor (gamut-clipped). Rewrap as Oklch.
95- return oklchToExpr ( ce , asOklch ( interpolateOklch ( palette [ i ] , palette [ i + 1 ] , frac ) ) ) ;
99+ return oklchToExpr (
100+ ce ,
101+ asOklch ( interpolateOklch ( palette [ i ] , palette [ i + 1 ] , frac ) )
102+ ) ;
96103}
97104
98105/** Heads recognized as color values. */
@@ -118,8 +125,7 @@ function readColorExpr(arg: any): {
118125 const c2 = arg . ops [ 2 ] . re ;
119126 if ( ! Number . isFinite ( c0 ) || ! Number . isFinite ( c1 ) || ! Number . isFinite ( c2 ) )
120127 return null ;
121- const alpha =
122- arg . ops . length >= 4 ? normalizeAlpha ( arg . ops [ 3 ] . re ) : undefined ;
128+ const alpha = arg . ops . length >= 4 ? normalizeAlpha ( arg . ops [ 3 ] . re ) : undefined ;
123129 return { space : arg . operator , c0, c1, c2, alpha } ;
124130}
125131
@@ -378,7 +384,8 @@ export const COLORS_LIBRARY: SymbolDefinitions = {
378384 ColorMix : {
379385 description : 'Mix two colors in OKLCh space' ,
380386 complexity : 8000 ,
381- signature : '(color | string | tuple, color | string | tuple, number?) -> color' ,
387+ signature :
388+ '(color | string | tuple, color | string | tuple, number?) -> color' ,
382389 evaluate : ( ops , { engine : ce } ) => {
383390 let ratio = 0.5 ;
384391 if ( ops . length >= 3 && ops [ 2 ] !== undefined ) {
@@ -580,7 +587,8 @@ export const COLORS_LIBRARY: SymbolDefinitions = {
580587 description :
581588 'Choose the foreground color with better APCA contrast against a background' ,
582589 complexity : 8000 ,
583- signature : '(color | string | tuple, (color | string | tuple)?, (color | string | tuple)?) -> color' ,
590+ signature :
591+ '(color | string | tuple, (color | string | tuple)?, (color | string | tuple)?) -> color' ,
584592 evaluate : ( ops , { engine : ce } ) => {
585593 const bgRgb = extractRgb ( ce , ops [ 0 ] ) ;
586594 if ( ! bgRgb ) return ce . error ( 'incompatible-type' ) ;
@@ -621,12 +629,14 @@ export const COLORS_LIBRARY: SymbolDefinitions = {
621629 signature : '(number, number, number, number?) -> color' ,
622630 } ,
623631 Hsv : {
624- description : 'HSV color (hue degrees, saturation/value 0-1, optional alpha)' ,
632+ description :
633+ 'HSV color (hue degrees, saturation/value 0-1, optional alpha)' ,
625634 complexity : 8000 ,
626635 signature : '(number, number, number, number?) -> color' ,
627636 } ,
628637 Hsl : {
629- description : 'HSL color (hue degrees, saturation/lightness 0-1, optional alpha)' ,
638+ description :
639+ 'HSL color (hue degrees, saturation/lightness 0-1, optional alpha)' ,
630640 complexity : 8000 ,
631641 signature : '(number, number, number, number?) -> color' ,
632642 } ,
@@ -743,7 +753,11 @@ export const COLORS_LIBRARY: SymbolDefinitions = {
743753 b : c . c2 ,
744754 alpha : c . alpha ,
745755 } ) ;
746- const args = [ ce . number ( oklch . L ) , ce . number ( oklch . C ) , ce . number ( oklch . H ) ] ;
756+ const args = [
757+ ce . number ( oklch . L ) ,
758+ ce . number ( oklch . C ) ,
759+ ce . number ( oklch . H ) ,
760+ ] ;
747761 if ( oklch . alpha !== undefined ) args . push ( ce . number ( oklch . alpha ) ) ;
748762 return ce . function ( 'Oklch' , args ) ;
749763 }
0 commit comments