Skip to content

Commit 6cf59dd

Browse files
committed
chore: lint
1 parent b0faee0 commit 6cf59dd

4 files changed

Lines changed: 30 additions & 19 deletions

File tree

src/api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10276,6 +10276,7 @@ type PrimitiveType =
1027610276
| "symbol"
1027710277
| "boolean"
1027810278
| "string"
10279+
| "color"
1027910280
| "expression"
1028010281
| "unknown"
1028110282
| "error"

src/compute-engine/compilation/javascript-target.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -807,8 +807,7 @@ const JAVASCRIPT_FUNCTIONS: CompiledFunctions<Expression> = {
807807
// The GPU target maps `Distance` to the GLSL/WGSL `distance()` builtin
808808
// (vec-only); this JS handler works on plain arrays of any length.
809809
Distance: ([a, b], compile) => {
810-
if (a === null || b === null)
811-
throw new Error('Distance: need two points');
810+
if (a === null || b === null) throw new Error('Distance: need two points');
812811
return `_SYS.distance(${compile(a)}, ${compile(b)})`;
813812
},
814813
};
@@ -1184,9 +1183,7 @@ const colorHelpers = {
11841183
const r = rgb.r / 255;
11851184
const g = rgb.g / 255;
11861185
const b = rgb.b / 255;
1187-
return rgb.alpha !== undefined
1188-
? [r, g, b, rgb.alpha]
1189-
: [r, g, b];
1186+
return rgb.alpha !== undefined ? [r, g, b, rgb.alpha] : [r, g, b];
11901187
},
11911188
asHsv(input: string | number[]): number[] {
11921189
const rgb = toRgb255(input);
@@ -1223,8 +1220,7 @@ const colorHelpers = {
12231220
distance(a: number[], b: number[]): number {
12241221
if (!Array.isArray(a) || !Array.isArray(b))
12251222
throw new Error('Distance: expected two arrays');
1226-
if (a.length !== b.length)
1227-
throw new Error('Distance: dimension mismatch');
1223+
if (a.length !== b.length) throw new Error('Distance: dimension mismatch');
12281224
let sumSq = 0;
12291225
for (let i = 0; i < a.length; i++) {
12301226
const d = a[i] - b[i];

src/compute-engine/library/arithmetic.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1860,12 +1860,12 @@ export const ARITHMETIC_LIBRARY: SymbolDefinitions[] = [
18601860
},
18611861

18621862
Distance: {
1863-
description:
1864-
'Euclidean distance between two points (tuples of numbers).',
1863+
description: 'Euclidean distance between two points (tuples of numbers).',
18651864
complexity: 6000,
18661865
signature: '(tuple, tuple) -> number',
18671866
evaluate: ([a, b], { engine: ce }) => {
1868-
if (!isFunction(a) || !isFunction(b)) return ce.error('incompatible-type');
1867+
if (!isFunction(a) || !isFunction(b))
1868+
return ce.error('incompatible-type');
18691869
if (a.operator !== 'Tuple' || b.operator !== 'Tuple')
18701870
return ce.error('incompatible-type');
18711871
if (a.ops!.length !== b.ops!.length || a.ops!.length === 0)

src/compute-engine/library/colors.ts

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ import {
2121
DIVERGING_PALETTES,
2222
} from '@arnog/colors';
2323
import 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

Comments
 (0)