@flighthq/adjustments 0.5.1-next.920.da8f530 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/.tsbuildinfo.contract +1 -0
- package/dist/.tsbuildinfo.runtime +1 -0
- package/dist/adjustment.d.ts +2 -1
- package/dist/adjustment.d.ts.map +1 -1
- package/dist/adjustment.js.map +1 -1
- package/dist/brightnessContrastAdjustment.d.ts +2 -1
- package/dist/brightnessContrastAdjustment.d.ts.map +1 -1
- package/dist/brightnessContrastAdjustment.js +6 -6
- package/dist/brightnessContrastAdjustment.js.map +1 -1
- package/dist/channelMixerAdjustment.d.ts +2 -1
- package/dist/channelMixerAdjustment.d.ts.map +1 -1
- package/dist/channelMixerAdjustment.js +4 -4
- package/dist/channelMixerAdjustment.js.map +1 -1
- package/dist/colorAdjustmentResolution.d.ts +3 -3
- package/dist/colorAdjustmentResolution.d.ts.map +1 -1
- package/dist/colorAdjustmentResolution.js +2 -2
- package/dist/colorAdjustmentResolution.js.map +1 -1
- package/dist/colorBlindSimulationAdjustment.d.ts +2 -1
- package/dist/colorBlindSimulationAdjustment.d.ts.map +1 -1
- package/dist/colorBlindSimulationAdjustment.js +5 -5
- package/dist/colorBlindSimulationAdjustment.js.map +1 -1
- package/dist/colorGradeAdjustment.d.ts +2 -1
- package/dist/colorGradeAdjustment.d.ts.map +1 -1
- package/dist/colorGradeAdjustment.js +3 -3
- package/dist/colorGradeAdjustment.js.map +1 -1
- package/dist/colorLut.d.ts +1 -1
- package/dist/colorLut.d.ts.map +1 -1
- package/dist/colorLut.js.map +1 -1
- package/dist/colorLutAdjustment.d.ts +2 -1
- package/dist/colorLutAdjustment.d.ts.map +1 -1
- package/dist/colorLutAdjustment.js +3 -3
- package/dist/colorLutAdjustment.js.map +1 -1
- package/dist/colorLutCache.d.ts +2 -1
- package/dist/colorLutCache.d.ts.map +1 -1
- package/dist/colorLutCache.js +4 -4
- package/dist/colorLutCache.js.map +1 -1
- package/dist/colorMatrixAdjustment.d.ts +5 -4
- package/dist/colorMatrixAdjustment.d.ts.map +1 -1
- package/dist/colorMatrixAdjustment.js +7 -7
- package/dist/colorMatrixAdjustment.js.map +1 -1
- package/dist/colorMatrixMath.d.ts +23 -24
- package/dist/colorMatrixMath.d.ts.map +1 -1
- package/dist/colorMatrixMath.js +58 -61
- package/dist/colorMatrixMath.js.map +1 -1
- package/dist/colorScaleBiasAdjustment.d.ts +2 -1
- package/dist/colorScaleBiasAdjustment.d.ts.map +1 -1
- package/dist/colorScaleBiasAdjustment.js +5 -5
- package/dist/colorScaleBiasAdjustment.js.map +1 -1
- package/dist/contract.adjustments-types.d.ts +2 -0
- package/dist/contract.adjustments-types.d.ts.map +1 -0
- package/dist/contract.adjustments-types.js +2 -0
- package/dist/contract.adjustments-types.js.map +1 -0
- package/dist/contract.d.ts +21 -34
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +20 -34
- package/dist/contract.js.map +1 -1
- package/dist/exposureAdjustment.d.ts +2 -1
- package/dist/exposureAdjustment.d.ts.map +1 -1
- package/dist/exposureAdjustment.js +5 -5
- package/dist/exposureAdjustment.js.map +1 -1
- package/dist/grayscaleAdjustment.d.ts +2 -1
- package/dist/grayscaleAdjustment.d.ts.map +1 -1
- package/dist/grayscaleAdjustment.js +5 -5
- package/dist/grayscaleAdjustment.js.map +1 -1
- package/dist/hueSaturationAdjustment.d.ts +2 -1
- package/dist/hueSaturationAdjustment.d.ts.map +1 -1
- package/dist/hueSaturationAdjustment.js +3 -3
- package/dist/hueSaturationAdjustment.js.map +1 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -1
- package/dist/index.js.map +1 -1
- package/dist/invertAdjustment.d.ts +2 -1
- package/dist/invertAdjustment.d.ts.map +1 -1
- package/dist/invertAdjustment.js +5 -5
- package/dist/invertAdjustment.js.map +1 -1
- package/dist/liftGammaGainAdjustment.d.ts +2 -1
- package/dist/liftGammaGainAdjustment.d.ts.map +1 -1
- package/dist/liftGammaGainAdjustment.js +3 -3
- package/dist/liftGammaGainAdjustment.js.map +1 -1
- package/dist/lookupTableGradeAdjustment.d.ts +2 -1
- package/dist/lookupTableGradeAdjustment.d.ts.map +1 -1
- package/dist/lookupTableGradeAdjustment.js +4 -4
- package/dist/lookupTableGradeAdjustment.js.map +1 -1
- package/dist/sepiaAdjustment.d.ts +2 -1
- package/dist/sepiaAdjustment.d.ts.map +1 -1
- package/dist/sepiaAdjustment.js +5 -5
- package/dist/sepiaAdjustment.js.map +1 -1
- package/dist/tintAdjustment.d.ts +2 -1
- package/dist/tintAdjustment.d.ts.map +1 -1
- package/dist/tintAdjustment.js +5 -5
- package/dist/tintAdjustment.js.map +1 -1
- package/dist/types.d.ts +119 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +5 -4
- package/src/adjustment.test.ts +1 -1
- package/src/brightnessContrastAdjustment.test.ts +6 -6
- package/src/channelMixerAdjustment.test.ts +5 -5
- package/src/colorAdjustmentResolution.test.ts +17 -11
- package/src/colorBlindSimulationAdjustment.test.ts +7 -7
- package/src/colorGradeAdjustment.test.ts +1 -1
- package/src/colorLut.test.ts +2 -3
- package/src/colorLutAdjustment.test.ts +7 -3
- package/src/colorLutCache.test.ts +5 -5
- package/src/colorMatrixAdjustment.test.ts +3 -3
- package/src/colorMatrixMath.test.ts +20 -12
- package/src/colorScaleBiasAdjustment.test.ts +1 -1
- package/src/exposureAdjustment.test.ts +5 -5
- package/src/grayscaleAdjustment.test.ts +4 -4
- package/src/hueSaturationAdjustment.test.ts +1 -1
- package/src/invertAdjustment.test.ts +6 -6
- package/src/liftGammaGainAdjustment.test.ts +1 -1
- package/src/lookupTableGradeAdjustment.test.ts +5 -2
- package/src/sepiaAdjustment.test.ts +4 -4
- package/src/tintAdjustment.test.ts +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sepiaAdjustment.js","sourceRoot":"","sources":["../src/sepiaAdjustment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"sepiaAdjustment.js","sourceRoot":"","sources":["../src/sepiaAdjustment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAG3D,OAAO,EAAE,+BAA+B,EAAE,MAAM,4BAA4B,CAAC;AAG7E,MAAM,UAAU,qBAAqB,CACnC,OAAO,GAAsF,EAAE;IAE/F,MAAM,GAAG,GAAG,cAAc,EAAmB,CAAC;IAC9C,yBAAyB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACxC,OAAO,GAAG,CAAC;AACb,CAAC;AAED,sGAAsG;AACtG,8FAA8F;AAC9F,MAAM,UAAU,yBAAyB,CACvC,GAAwC,EACxC,OAAO,GAAsF,EAAE;IAE/F,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,CAAC,CAAC;IACzC,MAAM,CAAC,GAAG,SAAS,CAAC;IACpB,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAChB,kBAAkB;IAClB,MAAM,WAAW,GAAG,IAAI,YAAY,CAAC;QACnC,CAAC,GAAG,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;QACzC,KAAK,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;QACzC,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;QACzC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;KACd,CAAC,CAAC;IACH,+BAA+B,CAAC,GAAG,EAAE,iBAAiB,EAAE,WAAW,CAAC,CAAC;IACrE,GAAG,CAAC,SAAS,GAAG,SAAS,CAAC;AAC5B,CAAC"}
|
package/dist/tintAdjustment.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { EntityConstruction } from '@flighthq/entity/contract';
|
|
2
|
+
import type { TintAdjustment } from './types.ts';
|
|
2
3
|
export declare function createTintAdjustment(rgba: number): TintAdjustment;
|
|
3
4
|
export declare function initializeTintAdjustment(out: EntityConstruction<TintAdjustment>, rgba: number): void;
|
|
4
5
|
//# sourceMappingURL=tintAdjustment.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tintAdjustment.d.ts","sourceRoot":"","sources":["../src/tintAdjustment.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"tintAdjustment.d.ts","sourceRoot":"","sources":["../src/tintAdjustment.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAGpE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAIjE;AAMD,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,kBAAkB,CAAC,cAAc,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAapG"}
|
package/dist/tintAdjustment.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { allocateEntity
|
|
2
|
-
import { initializeColorMatrixAdjustment } from './colorMatrixAdjustment';
|
|
1
|
+
import { allocateEntity } from '@flighthq/entity/contract';
|
|
2
|
+
import { initializeColorMatrixAdjustment } from './colorMatrixAdjustment.js';
|
|
3
3
|
export function createTintAdjustment(rgba) {
|
|
4
4
|
const out = allocateEntity();
|
|
5
5
|
initializeTintAdjustment(out, rgba);
|
|
6
|
-
return
|
|
6
|
+
return out;
|
|
7
7
|
}
|
|
8
8
|
// Builds a diagonal-affine tint from a packed `0xRRGGBBAA` color: each channel scale is that byte
|
|
9
9
|
// divided by 255, with zero bias and no channel mixing. Matrix-tier, so it fuses with other adjustments
|
|
@@ -15,12 +15,12 @@ export function initializeTintAdjustment(out, rgba) {
|
|
|
15
15
|
const blueScale = ((rgba >>> 8) & 0xff) / 255;
|
|
16
16
|
const alphaScale = (rgba & 0xff) / 255;
|
|
17
17
|
// prettier-ignore
|
|
18
|
-
const colorMatrix = [
|
|
18
|
+
const colorMatrix = new Float32Array([
|
|
19
19
|
redScale, 0, 0, 0, 0,
|
|
20
20
|
0, greenScale, 0, 0, 0,
|
|
21
21
|
0, 0, blueScale, 0, 0,
|
|
22
22
|
0, 0, 0, alphaScale, 0,
|
|
23
|
-
];
|
|
23
|
+
]);
|
|
24
24
|
initializeColorMatrixAdjustment(out, 'TintAdjustment', colorMatrix);
|
|
25
25
|
}
|
|
26
26
|
//# sourceMappingURL=tintAdjustment.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tintAdjustment.js","sourceRoot":"","sources":["../src/tintAdjustment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"tintAdjustment.js","sourceRoot":"","sources":["../src/tintAdjustment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAG3D,OAAO,EAAE,+BAA+B,EAAE,MAAM,4BAA4B,CAAC;AAG7E,MAAM,UAAU,oBAAoB,CAAC,IAAY;IAC/C,MAAM,GAAG,GAAG,cAAc,EAAkB,CAAC;IAC7C,wBAAwB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACpC,OAAO,GAAG,CAAC;AACb,CAAC;AAED,kGAAkG;AAClG,wGAAwG;AACxG,yGAAyG;AACzG,uGAAuG;AACvG,MAAM,UAAU,wBAAwB,CAAC,GAAuC,EAAE,IAAY;IAC5F,MAAM,QAAQ,GAAG,CAAC,CAAC,IAAI,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,GAAG,CAAC;IAC9C,MAAM,UAAU,GAAG,CAAC,CAAC,IAAI,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,GAAG,CAAC;IAChD,MAAM,SAAS,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,GAAG,CAAC;IAC9C,MAAM,UAAU,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,GAAG,CAAC;IACvC,kBAAkB;IAClB,MAAM,WAAW,GAAG,IAAI,YAAY,CAAC;QACnC,QAAQ,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;QACpB,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;QACtB,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;QACrB,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC;KACvB,CAAC,CAAC;IACH,+BAA+B,CAAC,GAAG,EAAE,gBAAgB,EAAE,WAAW,CAAC,CAAC;AACtE,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type { EntityRaw, EntityRuntime, EntityRuntimeKey, EntityWithoutRuntime } from '@flighthq/entity/contract';
|
|
2
|
+
export interface Adjustment extends EntityRaw {
|
|
3
|
+
[EntityRuntimeKey]: EntityRuntime | undefined;
|
|
4
|
+
kind: AdjustmentKind;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Identifies a pointwise value-remap adjustment for realization dispatch. An open-registry string
|
|
8
|
+
* key: the canonical PascalCase type name (`'ColorScaleBiasAdjustment'`, `'Brightness'`), simultaneously the
|
|
9
|
+
* registry key and the serialized form. Third-party adjustments namespace with a vendor prefix
|
|
10
|
+
* (`'acme.Duotone'`). Concrete kinds are declared by the packages that own them.
|
|
11
|
+
*/
|
|
12
|
+
export type AdjustmentKind = string;
|
|
13
|
+
export interface BrightnessContrastAdjustment extends ColorMatrixAdjustment {
|
|
14
|
+
kind: 'BrightnessContrastAdjustment';
|
|
15
|
+
brightness?: number;
|
|
16
|
+
contrast?: number;
|
|
17
|
+
}
|
|
18
|
+
export interface ChannelMixerAdjustment extends ColorMatrixAdjustment {
|
|
19
|
+
kind: 'ChannelMixerAdjustment';
|
|
20
|
+
matrix: readonly number[];
|
|
21
|
+
}
|
|
22
|
+
export interface ColorAdjustmentRuntime {
|
|
23
|
+
colorAdjustments: readonly Adjustment[] | null;
|
|
24
|
+
colorAdjustmentsUnsupported: boolean;
|
|
25
|
+
resolvedColorMatrix: Readonly<Float32Array> | null;
|
|
26
|
+
resolvedColorScaleBias: ColorScaleBias | null;
|
|
27
|
+
}
|
|
28
|
+
export type ColorBlindType = 'protanopia' | 'deuteranopia' | 'tritanopia' | 'protanomaly' | 'deuteranomaly' | 'tritanomaly' | 'achromatopsia' | 'achromatomaly';
|
|
29
|
+
export interface ColorBlindSimulationAdjustment extends ColorMatrixAdjustment {
|
|
30
|
+
kind: 'ColorBlindSimulationAdjustment';
|
|
31
|
+
type?: ColorBlindType;
|
|
32
|
+
}
|
|
33
|
+
export interface ColorGradeAdjustment extends ColorLutAdjustment {
|
|
34
|
+
kind: 'ColorGradeAdjustment';
|
|
35
|
+
exposure?: number;
|
|
36
|
+
brightness?: number;
|
|
37
|
+
contrast?: number;
|
|
38
|
+
saturation?: number;
|
|
39
|
+
temperature?: number;
|
|
40
|
+
tint?: number;
|
|
41
|
+
lift?: number;
|
|
42
|
+
gamma?: number;
|
|
43
|
+
gain?: number;
|
|
44
|
+
}
|
|
45
|
+
export interface ColorLut {
|
|
46
|
+
size: number;
|
|
47
|
+
samples: readonly number[];
|
|
48
|
+
}
|
|
49
|
+
export interface ColorLutAdjustment extends Adjustment {
|
|
50
|
+
transform: ColorTransformFunction;
|
|
51
|
+
}
|
|
52
|
+
export interface ColorLutCache extends EntityRaw {
|
|
53
|
+
[EntityRuntimeKey]: EntityRuntime | undefined;
|
|
54
|
+
signature: string | null;
|
|
55
|
+
lut: ColorLut | null;
|
|
56
|
+
}
|
|
57
|
+
export interface ColorMatrixAdjustment extends Adjustment {
|
|
58
|
+
colorMatrix: Readonly<Float32Array>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Per-channel affine color adjustment: `out = in * scale + bias`.
|
|
62
|
+
*
|
|
63
|
+
* Scale is dimensionless. Bias is an unbounded normalized-linear float, where `1` adds one full
|
|
64
|
+
* channel of intensity; byte-domain consumers convert it at their boundary.
|
|
65
|
+
*/
|
|
66
|
+
export interface ColorScaleBias extends EntityRaw {
|
|
67
|
+
[EntityRuntimeKey]: EntityRuntime | undefined;
|
|
68
|
+
alphaScale: number;
|
|
69
|
+
alphaBias: number;
|
|
70
|
+
blueScale: number;
|
|
71
|
+
blueBias: number;
|
|
72
|
+
greenScale: number;
|
|
73
|
+
greenBias: number;
|
|
74
|
+
redScale: number;
|
|
75
|
+
redBias: number;
|
|
76
|
+
}
|
|
77
|
+
export type ColorScaleBiasLike = EntityWithoutRuntime<ColorScaleBias>;
|
|
78
|
+
export interface ColorScaleBiasAdjustment extends ColorMatrixAdjustment {
|
|
79
|
+
colorScaleBias: Readonly<ColorScaleBiasLike>;
|
|
80
|
+
kind: 'ColorScaleBiasAdjustment';
|
|
81
|
+
}
|
|
82
|
+
export type ColorTransformFunction = (out: [number, number, number], r: number, g: number, b: number) => void;
|
|
83
|
+
export interface ExposureAdjustment extends ColorMatrixAdjustment {
|
|
84
|
+
kind: 'ExposureAdjustment';
|
|
85
|
+
exposure?: number;
|
|
86
|
+
}
|
|
87
|
+
export interface GrayscaleAdjustment extends ColorMatrixAdjustment {
|
|
88
|
+
kind: 'GrayscaleAdjustment';
|
|
89
|
+
intensity?: number;
|
|
90
|
+
}
|
|
91
|
+
export interface HueSaturationAdjustment extends ColorLutAdjustment {
|
|
92
|
+
kind: 'HueSaturationAdjustment';
|
|
93
|
+
hue?: number;
|
|
94
|
+
saturation?: number;
|
|
95
|
+
lightness?: number;
|
|
96
|
+
}
|
|
97
|
+
export interface InvertAdjustment extends ColorMatrixAdjustment {
|
|
98
|
+
kind: 'InvertAdjustment';
|
|
99
|
+
intensity?: number;
|
|
100
|
+
}
|
|
101
|
+
export interface LiftGammaGainAdjustment extends ColorLutAdjustment {
|
|
102
|
+
kind: 'LiftGammaGainAdjustment';
|
|
103
|
+
lift?: number;
|
|
104
|
+
gamma?: number;
|
|
105
|
+
gain?: number;
|
|
106
|
+
}
|
|
107
|
+
export interface LookupTableGradeAdjustment extends ColorLutAdjustment {
|
|
108
|
+
kind: 'LookupTableGradeAdjustment';
|
|
109
|
+
lut?: ColorLut;
|
|
110
|
+
strength?: number;
|
|
111
|
+
}
|
|
112
|
+
export interface SepiaAdjustment extends ColorMatrixAdjustment {
|
|
113
|
+
kind: 'SepiaAdjustment';
|
|
114
|
+
intensity?: number;
|
|
115
|
+
}
|
|
116
|
+
export interface TintAdjustment extends ColorMatrixAdjustment {
|
|
117
|
+
kind: 'TintAdjustment';
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"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"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/adjustments",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"author": "Joshua Granick and other contributors",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -32,17 +32,18 @@
|
|
|
32
32
|
"scripts": {
|
|
33
33
|
"build": "tsc -b",
|
|
34
34
|
"clean": "tsc -b --clean",
|
|
35
|
+
"generate": "tsx ../../scripts/generate-rust-package.ts --crate flight-adjustments --package adjustments",
|
|
36
|
+
"generate:check": "tsx ../../scripts/generate-rust-package.ts --crate flight-adjustments --package adjustments --check",
|
|
35
37
|
"test": "vitest run --config vitest.config.ts",
|
|
36
38
|
"test:watch": "vitest --watch --config vitest.config.ts",
|
|
37
39
|
"prepack": "npm run clean && npm run clean:dist && npm run build",
|
|
38
40
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
39
41
|
},
|
|
40
42
|
"dependencies": {
|
|
41
|
-
"@flighthq/entity": "0.
|
|
42
|
-
"@flighthq/types": "0.5.1-next.920.da8f530"
|
|
43
|
+
"@flighthq/entity": "0.6.0"
|
|
43
44
|
},
|
|
44
45
|
"devDependencies": {
|
|
45
|
-
"typescript": "^
|
|
46
|
+
"typescript": "^7.0.2"
|
|
46
47
|
},
|
|
47
48
|
"description": "Pointwise value-remap adjustment descriptors and color-matrix fuse math",
|
|
48
49
|
"sideEffects": false
|
package/src/adjustment.test.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createBrightnessContrastAdjustment,
|
|
3
3
|
initializeBrightnessContrastAdjustment,
|
|
4
|
-
} from './brightnessContrastAdjustment';
|
|
5
|
-
import { applyColorMatrixToColor } from './colorMatrixMath';
|
|
4
|
+
} from './brightnessContrastAdjustment.ts';
|
|
5
|
+
import { applyColorMatrixToColor } from './colorMatrixMath.ts';
|
|
6
6
|
|
|
7
7
|
describe('createBrightnessContrastAdjustment', () => {
|
|
8
8
|
it('defaults to the identity (brightness 0, contrast 1)', () => {
|
|
9
9
|
const adjustment = createBrightnessContrastAdjustment();
|
|
10
10
|
expect(adjustment.kind).toBe('BrightnessContrastAdjustment');
|
|
11
|
-
expect(applyColorMatrixToColor(adjustment.colorMatrix
|
|
11
|
+
expect(applyColorMatrixToColor(adjustment.colorMatrix, 0x3366aaff)).toBe(0x3366aaff);
|
|
12
12
|
});
|
|
13
13
|
|
|
14
14
|
it('scales contrast about mid-grey 0.5, leaving mid-grey fixed', () => {
|
|
15
15
|
const adjustment = createBrightnessContrastAdjustment({ contrast: 0.5 });
|
|
16
16
|
// 128 is the pivot → unchanged; black lifts toward mid-grey (255·0.5·0.5 = 63.75 → 64).
|
|
17
|
-
expect(applyColorMatrixToColor(adjustment.colorMatrix
|
|
18
|
-
expect(applyColorMatrixToColor(adjustment.colorMatrix
|
|
17
|
+
expect(applyColorMatrixToColor(adjustment.colorMatrix, 0x808080ff)).toBe(0x808080ff);
|
|
18
|
+
expect(applyColorMatrixToColor(adjustment.colorMatrix, 0x000000ff)).toBe(0x404040ff);
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
it('reproduces the prior shader (rgb + brightness − 0.5)·contrast + 0.5', () => {
|
|
22
22
|
// Scene3D values: brightness 0.15, contrast 0.35. White → (1 + 0.15 − 0.5)·0.35 + 0.5 = 0.7275 → 186.
|
|
23
23
|
const adjustment = createBrightnessContrastAdjustment({ brightness: 0.15, contrast: 0.35 });
|
|
24
|
-
expect(applyColorMatrixToColor(adjustment.colorMatrix
|
|
24
|
+
expect(applyColorMatrixToColor(adjustment.colorMatrix, 0xffffffff)).toBe(0xbababaff);
|
|
25
25
|
});
|
|
26
26
|
});
|
|
27
27
|
describe('initializeBrightnessContrastAdjustment', () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createChannelMixerAdjustment, initializeChannelMixerAdjustment } from './channelMixerAdjustment';
|
|
2
|
-
import { applyColorMatrixToColor } from './colorMatrixMath';
|
|
1
|
+
import { createChannelMixerAdjustment, initializeChannelMixerAdjustment } from './channelMixerAdjustment.ts';
|
|
2
|
+
import { applyColorMatrixToColor } from './colorMatrixMath.ts';
|
|
3
3
|
|
|
4
4
|
describe('createChannelMixerAdjustment', () => {
|
|
5
5
|
it('rotates channels via a 3×4 row-major mix and carries the fusable kind', () => {
|
|
@@ -8,18 +8,18 @@ describe('createChannelMixerAdjustment', () => {
|
|
|
8
8
|
expect(adjustment.kind).toBe('ChannelMixerAdjustment');
|
|
9
9
|
expect(adjustment.colorMatrix).toHaveLength(20);
|
|
10
10
|
// 0xAABBCC → R'=CC (from blue), G'=AA (from red), B'=BB (from green); alpha preserved.
|
|
11
|
-
expect(applyColorMatrixToColor(adjustment.colorMatrix
|
|
11
|
+
expect(applyColorMatrixToColor(adjustment.colorMatrix, 0xaabbccff)).toBe(0xccaabbff);
|
|
12
12
|
});
|
|
13
13
|
|
|
14
14
|
it('defaults to the identity mix', () => {
|
|
15
15
|
const adjustment = createChannelMixerAdjustment();
|
|
16
|
-
expect(applyColorMatrixToColor(adjustment.colorMatrix
|
|
16
|
+
expect(applyColorMatrixToColor(adjustment.colorMatrix, 0x123456ff)).toBe(0x123456ff);
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
it('applies the per-row offset in normalized 0–1, scaled to the 0–255 column', () => {
|
|
20
20
|
// Identity mix plus a full-white offset on every row → saturates to white.
|
|
21
21
|
const adjustment = createChannelMixerAdjustment({ matrix: [1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1] });
|
|
22
|
-
expect(applyColorMatrixToColor(adjustment.colorMatrix
|
|
22
|
+
expect(applyColorMatrixToColor(adjustment.colorMatrix, 0x102030ff)).toBe(0xffffffff);
|
|
23
23
|
});
|
|
24
24
|
});
|
|
25
25
|
describe('initializeChannelMixerAdjustment', () => {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { allocateEntity
|
|
2
|
-
import type { Adjustment, ColorMatrixAdjustment, ColorScaleBias } from '@flighthq/types/contract';
|
|
1
|
+
import { allocateEntity } from '@flighthq/entity/contract';
|
|
3
2
|
|
|
4
3
|
import {
|
|
5
4
|
COLOR_ADJUSTMENT_AFFINE,
|
|
@@ -8,9 +7,10 @@ import {
|
|
|
8
7
|
isAffineColorMatrix,
|
|
9
8
|
resolveColorAdjustmentsColorMatrix,
|
|
10
9
|
resolveColorAdjustmentsColorScaleBias,
|
|
11
|
-
} from './colorAdjustmentResolution';
|
|
12
|
-
import { createColorMatrixAdjustment } from './colorMatrixAdjustment';
|
|
13
|
-
import { createIdentityColorMatrix, createSaturationColorMatrix } from './colorMatrixMath';
|
|
10
|
+
} from './colorAdjustmentResolution.ts';
|
|
11
|
+
import { createColorMatrixAdjustment } from './colorMatrixAdjustment.ts';
|
|
12
|
+
import { createIdentityColorMatrix, createSaturationColorMatrix } from './colorMatrixMath.ts';
|
|
13
|
+
import type { Adjustment, ColorMatrixAdjustment, ColorScaleBias } from './types.ts';
|
|
14
14
|
|
|
15
15
|
function makeColorScaleBias(fields: Partial<ColorScaleBias> = {}): ColorScaleBias {
|
|
16
16
|
const out = allocateEntity<any>();
|
|
@@ -23,7 +23,7 @@ function makeColorScaleBias(fields: Partial<ColorScaleBias> = {}): ColorScaleBia
|
|
|
23
23
|
out.blueBias = 0;
|
|
24
24
|
out.alphaBias = 0;
|
|
25
25
|
Object.assign(out, fields);
|
|
26
|
-
return
|
|
26
|
+
return out as ColorScaleBias;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
describe('isAffineColorMatrix', () => {
|
|
@@ -52,7 +52,7 @@ describe('resolveColorAdjustmentsColorMatrix', () => {
|
|
|
52
52
|
(() => {
|
|
53
53
|
const out = allocateEntity<Adjustment>();
|
|
54
54
|
out.kind = 'acme.Lut';
|
|
55
|
-
return
|
|
55
|
+
return out;
|
|
56
56
|
})() as Adjustment,
|
|
57
57
|
]),
|
|
58
58
|
).toBeNull();
|
|
@@ -67,18 +67,24 @@ describe('resolveColorAdjustmentsColorScaleBias', () => {
|
|
|
67
67
|
});
|
|
68
68
|
|
|
69
69
|
it('resolves a single generic affine matrix exactly', () => {
|
|
70
|
-
const adjustment = createColorMatrixAdjustment(
|
|
70
|
+
const adjustment = createColorMatrixAdjustment(
|
|
71
|
+
new Float32Array([0.5, 0, 0, 0, 0.4, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0]),
|
|
72
|
+
);
|
|
71
73
|
const out = makeColorScaleBias();
|
|
72
74
|
expect(resolveColorAdjustmentsColorScaleBias([adjustment], out)).toBe(COLOR_ADJUSTMENT_AFFINE);
|
|
73
75
|
expect(out.redScale).toBe(0.5);
|
|
74
76
|
expect(out.greenScale).toBe(0);
|
|
75
|
-
expect(out.redBias).
|
|
77
|
+
expect(out.redBias).toBeCloseTo(0.4);
|
|
76
78
|
expect(out.alphaScale).toBe(1);
|
|
77
79
|
});
|
|
78
80
|
|
|
79
81
|
it('fuses two affine adjustments (multipliers compose)', () => {
|
|
80
|
-
const a = createColorMatrixAdjustment(
|
|
81
|
-
|
|
82
|
+
const a = createColorMatrixAdjustment(
|
|
83
|
+
new Float32Array([0.5, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0]),
|
|
84
|
+
);
|
|
85
|
+
const b = createColorMatrixAdjustment(
|
|
86
|
+
new Float32Array([0.5, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0]),
|
|
87
|
+
);
|
|
82
88
|
const out = makeColorScaleBias();
|
|
83
89
|
expect(resolveColorAdjustmentsColorScaleBias([a, b], out)).toBe(COLOR_ADJUSTMENT_AFFINE);
|
|
84
90
|
expect(out.redScale).toBe(0.25);
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createColorBlindSimulationAdjustment,
|
|
3
3
|
initializeColorBlindSimulationAdjustment,
|
|
4
|
-
} from './colorBlindSimulationAdjustment';
|
|
5
|
-
import { applyColorMatrixToColor } from './colorMatrixMath';
|
|
4
|
+
} from './colorBlindSimulationAdjustment.ts';
|
|
5
|
+
import { applyColorMatrixToColor } from './colorMatrixMath.ts';
|
|
6
6
|
|
|
7
7
|
describe('createColorBlindSimulationAdjustment', () => {
|
|
8
8
|
it('defaults to deuteranopia and bakes its linear matrix, preserving alpha', () => {
|
|
9
9
|
const adjustment = createColorBlindSimulationAdjustment();
|
|
10
10
|
expect(adjustment.kind).toBe('ColorBlindSimulationAdjustment');
|
|
11
11
|
expect(adjustment.colorMatrix).toHaveLength(20);
|
|
12
|
-
//
|
|
13
|
-
expect(applyColorMatrixToColor(adjustment.colorMatrix
|
|
12
|
+
// Float32 coefficients preserve Rust precision: pure red maps to R'=159, G'=178, B'=0.
|
|
13
|
+
expect(applyColorMatrixToColor(adjustment.colorMatrix, 0xff0000ff)).toBe(0x9fb200ff);
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
it('achromatopsia collapses to equal-channel luma (monochrome)', () => {
|
|
17
17
|
const adjustment = createColorBlindSimulationAdjustment({ type: 'achromatopsia' });
|
|
18
18
|
// Pure red → 0.299·255≈76 across all channels.
|
|
19
|
-
expect(applyColorMatrixToColor(adjustment.colorMatrix
|
|
19
|
+
expect(applyColorMatrixToColor(adjustment.colorMatrix, 0xff0000ff)).toBe(0x4c4c4cff);
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
it('selects a distinct matrix per type', () => {
|
|
23
23
|
const protan = createColorBlindSimulationAdjustment({ type: 'protanopia' });
|
|
24
24
|
const tritan = createColorBlindSimulationAdjustment({ type: 'tritanopia' });
|
|
25
25
|
const green = 0x00ff00ff;
|
|
26
|
-
expect(applyColorMatrixToColor(protan.colorMatrix
|
|
27
|
-
applyColorMatrixToColor(tritan.colorMatrix
|
|
26
|
+
expect(applyColorMatrixToColor(protan.colorMatrix, green)).not.toBe(
|
|
27
|
+
applyColorMatrixToColor(tritan.colorMatrix, green),
|
|
28
28
|
);
|
|
29
29
|
});
|
|
30
30
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createColorGradeAdjustment, initializeColorGradeAdjustment } from './colorGradeAdjustment';
|
|
1
|
+
import { createColorGradeAdjustment, initializeColorGradeAdjustment } from './colorGradeAdjustment.ts';
|
|
2
2
|
|
|
3
3
|
describe('createColorGradeAdjustment', () => {
|
|
4
4
|
it('defaults to approximately neutral (contrast 1, all stages near-neutral)', () => {
|
package/src/colorLut.test.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import { bakeColorLut, COLOR_LUT_DEFAULT_SIZE, sampleColorLut } from './colorLut';
|
|
1
|
+
import { bakeColorLut, COLOR_LUT_DEFAULT_SIZE, sampleColorLut } from './colorLut.ts';
|
|
2
|
+
import type { ColorTransformFunction } from './types.ts';
|
|
4
3
|
|
|
5
4
|
describe('bakeColorLut', () => {
|
|
6
5
|
it('bakes an empty stack into an identity LUT', () => {
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
getAdjustmentColorTransform,
|
|
3
|
+
initializeColorLutAdjustment,
|
|
4
|
+
isColorLutAdjustment,
|
|
5
|
+
} from './colorLutAdjustment.ts';
|
|
6
|
+
import { createHueSaturationAdjustment } from './hueSaturationAdjustment.ts';
|
|
7
|
+
import { createInvertAdjustment } from './invertAdjustment.ts';
|
|
4
8
|
|
|
5
9
|
describe('getAdjustmentColorTransform', () => {
|
|
6
10
|
it('returns a LUT-tier adjustment its own transform', () => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { createColorGradeAdjustment } from './colorGradeAdjustment';
|
|
2
|
-
import { bakeColorLut } from './colorLut';
|
|
3
|
-
import { getAdjustmentColorTransform } from './colorLutAdjustment';
|
|
4
|
-
import { bakeColorLutForRun, createColorLutCache, initializeColorLutCache } from './colorLutCache';
|
|
5
|
-
import { createHueSaturationAdjustment } from './hueSaturationAdjustment';
|
|
1
|
+
import { createColorGradeAdjustment } from './colorGradeAdjustment.ts';
|
|
2
|
+
import { bakeColorLut } from './colorLut.ts';
|
|
3
|
+
import { getAdjustmentColorTransform } from './colorLutAdjustment.ts';
|
|
4
|
+
import { bakeColorLutForRun, createColorLutCache, initializeColorLutCache } from './colorLutCache.ts';
|
|
5
|
+
import { createHueSaturationAdjustment } from './hueSaturationAdjustment.ts';
|
|
6
6
|
|
|
7
7
|
describe('bakeColorLutForRun', () => {
|
|
8
8
|
it('reuses the same ColorLut reference for a content-identical run rebuilt with fresh objects', () => {
|
|
@@ -3,9 +3,9 @@ import {
|
|
|
3
3
|
getAdjustmentColorMatrix,
|
|
4
4
|
initializeColorMatrixAdjustment,
|
|
5
5
|
isColorMatrixAdjustment,
|
|
6
|
-
} from './colorMatrixAdjustment';
|
|
7
|
-
import { createIdentityColorMatrix } from './colorMatrixMath';
|
|
8
|
-
import { createInvertAdjustment } from './invertAdjustment';
|
|
6
|
+
} from './colorMatrixAdjustment.ts';
|
|
7
|
+
import { createIdentityColorMatrix } from './colorMatrixMath.ts';
|
|
8
|
+
import { createInvertAdjustment } from './invertAdjustment.ts';
|
|
9
9
|
|
|
10
10
|
describe('createColorMatrixAdjustment', () => {
|
|
11
11
|
it('creates an authored generic matrix adjustment without a parallel transform payload', () => {
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
createWhiteBalanceColorMatrix,
|
|
23
23
|
fuseColorMatrices,
|
|
24
24
|
multiplyColorMatrix,
|
|
25
|
-
} from './colorMatrixMath';
|
|
25
|
+
} from './colorMatrixMath.ts';
|
|
26
26
|
|
|
27
27
|
const WHITE = 0xffffffff;
|
|
28
28
|
const BLACK = 0x000000ff;
|
|
@@ -216,8 +216,10 @@ describe('createHueRotateColorMatrix', () => {
|
|
|
216
216
|
});
|
|
217
217
|
|
|
218
218
|
describe('createIdentityColorMatrix', () => {
|
|
219
|
-
it('returns a 20-element
|
|
220
|
-
|
|
219
|
+
it('returns a 20-element Float32Array', () => {
|
|
220
|
+
const matrix = createIdentityColorMatrix();
|
|
221
|
+
expect(matrix).toBeInstanceOf(Float32Array);
|
|
222
|
+
expect(matrix).toHaveLength(COLOR_MATRIX_LENGTH);
|
|
221
223
|
});
|
|
222
224
|
|
|
223
225
|
it('leaves red unchanged', () => {
|
|
@@ -369,7 +371,10 @@ describe('fuseColorMatrices', () => {
|
|
|
369
371
|
const b = createGrayscaleColorMatrix();
|
|
370
372
|
const c = createContrastColorMatrix(1.5);
|
|
371
373
|
// Applying `a` then `b` then `c` = c × b × a as a single composed matrix (no per-scene2d rounding).
|
|
372
|
-
const
|
|
374
|
+
const ba = new Float32Array(20);
|
|
375
|
+
const expected = new Float32Array(20);
|
|
376
|
+
multiplyColorMatrix(ba, b, a);
|
|
377
|
+
multiplyColorMatrix(expected, c, ba);
|
|
373
378
|
const fused = fuseColorMatrices([a, b, c]);
|
|
374
379
|
for (let i = 0; i < 20; i++) expect(fused[i]).toBeCloseTo(expected[i], 10);
|
|
375
380
|
});
|
|
@@ -396,7 +401,8 @@ describe('fuseColorMatrices', () => {
|
|
|
396
401
|
describe('multiplyColorMatrix', () => {
|
|
397
402
|
it('identity ∘ identity = identity', () => {
|
|
398
403
|
const identity = createIdentityColorMatrix();
|
|
399
|
-
const result =
|
|
404
|
+
const result = new Float32Array(20);
|
|
405
|
+
multiplyColorMatrix(result, identity, identity);
|
|
400
406
|
for (let i = 0; i < 20; i++) {
|
|
401
407
|
expect(result[i]).toBeCloseTo(identity[i]);
|
|
402
408
|
}
|
|
@@ -404,16 +410,17 @@ describe('multiplyColorMatrix', () => {
|
|
|
404
410
|
|
|
405
411
|
it('writes to out when provided', () => {
|
|
406
412
|
const identity = createIdentityColorMatrix();
|
|
407
|
-
const out = new
|
|
408
|
-
|
|
409
|
-
expect(
|
|
413
|
+
const out = new Float32Array(20);
|
|
414
|
+
multiplyColorMatrix(out, identity, identity);
|
|
415
|
+
expect(out).toEqual(identity);
|
|
410
416
|
});
|
|
411
417
|
|
|
412
418
|
it('is alias-safe when out === a', () => {
|
|
413
419
|
const a = createGrayscaleColorMatrix();
|
|
414
420
|
const b = createIdentityColorMatrix();
|
|
415
|
-
const expected =
|
|
416
|
-
multiplyColorMatrix(a, b
|
|
421
|
+
const expected = new Float32Array(20);
|
|
422
|
+
multiplyColorMatrix(expected, a, b);
|
|
423
|
+
multiplyColorMatrix(a, a, b);
|
|
417
424
|
for (let i = 0; i < 20; i++) {
|
|
418
425
|
expect(a[i]).toBeCloseTo(expected[i]);
|
|
419
426
|
}
|
|
@@ -422,8 +429,9 @@ describe('multiplyColorMatrix', () => {
|
|
|
422
429
|
it('is alias-safe when out === b', () => {
|
|
423
430
|
const a = createIdentityColorMatrix();
|
|
424
431
|
const b = createGrayscaleColorMatrix();
|
|
425
|
-
const expected =
|
|
426
|
-
multiplyColorMatrix(
|
|
432
|
+
const expected = new Float32Array(20);
|
|
433
|
+
multiplyColorMatrix(expected, a, b);
|
|
434
|
+
multiplyColorMatrix(b, a, b);
|
|
427
435
|
for (let i = 0; i < 20; i++) {
|
|
428
436
|
expect(b[i]).toBeCloseTo(expected[i]);
|
|
429
437
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createColorScaleBiasAdjustment, initializeColorScaleBiasAdjustment } from './colorScaleBiasAdjustment';
|
|
1
|
+
import { createColorScaleBiasAdjustment, initializeColorScaleBiasAdjustment } from './colorScaleBiasAdjustment.ts';
|
|
2
2
|
|
|
3
3
|
describe('createColorScaleBiasAdjustment', () => {
|
|
4
4
|
it('keeps a legible bridge payload and contributes its diagonal matrix', () => {
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { applyColorMatrixToColor } from './colorMatrixMath';
|
|
2
|
-
import { createExposureAdjustment, initializeExposureAdjustment } from './exposureAdjustment';
|
|
1
|
+
import { applyColorMatrixToColor } from './colorMatrixMath.ts';
|
|
2
|
+
import { createExposureAdjustment, initializeExposureAdjustment } from './exposureAdjustment.ts';
|
|
3
3
|
|
|
4
4
|
describe('createExposureAdjustment', () => {
|
|
5
5
|
it('defaults to the identity (exposure 0)', () => {
|
|
6
6
|
const adjustment = createExposureAdjustment();
|
|
7
7
|
expect(adjustment.kind).toBe('ExposureAdjustment');
|
|
8
|
-
expect(applyColorMatrixToColor(adjustment.colorMatrix
|
|
8
|
+
expect(applyColorMatrixToColor(adjustment.colorMatrix, 0x204060ff)).toBe(0x204060ff);
|
|
9
9
|
});
|
|
10
10
|
|
|
11
11
|
it('scales RGB by 2^exposure, preserving alpha', () => {
|
|
12
12
|
const adjustment = createExposureAdjustment({ exposure: 1 });
|
|
13
13
|
// Each channel doubles; alpha is untouched.
|
|
14
|
-
expect(applyColorMatrixToColor(adjustment.colorMatrix
|
|
14
|
+
expect(applyColorMatrixToColor(adjustment.colorMatrix, 0x204060ff)).toBe(0x4080c0ff);
|
|
15
15
|
});
|
|
16
16
|
|
|
17
17
|
it('clamps to SDR [0,1] for the default pipeline', () => {
|
|
18
18
|
const adjustment = createExposureAdjustment({ exposure: 1 });
|
|
19
19
|
// 0x80 doubled is 256 → clamps to 255.
|
|
20
|
-
expect(applyColorMatrixToColor(adjustment.colorMatrix
|
|
20
|
+
expect(applyColorMatrixToColor(adjustment.colorMatrix, 0x808080ff)).toBe(0xffffffff);
|
|
21
21
|
});
|
|
22
22
|
});
|
|
23
23
|
describe('initializeExposureAdjustment', () => {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { applyColorMatrixToColor } from './colorMatrixMath';
|
|
2
|
-
import { createGrayscaleAdjustment, initializeGrayscaleAdjustment } from './grayscaleAdjustment';
|
|
1
|
+
import { applyColorMatrixToColor } from './colorMatrixMath.ts';
|
|
2
|
+
import { createGrayscaleAdjustment, initializeGrayscaleAdjustment } from './grayscaleAdjustment.ts';
|
|
3
3
|
|
|
4
4
|
describe('createGrayscaleAdjustment', () => {
|
|
5
5
|
it('defaults to full BT.709 luma desaturation', () => {
|
|
6
6
|
const adjustment = createGrayscaleAdjustment();
|
|
7
7
|
expect(adjustment.kind).toBe('GrayscaleAdjustment');
|
|
8
8
|
// Pure red → luma 0.2126·255 ≈ 54, equal across channels; alpha preserved.
|
|
9
|
-
const out = applyColorMatrixToColor(adjustment.colorMatrix
|
|
9
|
+
const out = applyColorMatrixToColor(adjustment.colorMatrix, 0xff0000ff);
|
|
10
10
|
const r = (out >>> 24) & 0xff;
|
|
11
11
|
const g = (out >>> 16) & 0xff;
|
|
12
12
|
const b = (out >>> 8) & 0xff;
|
|
@@ -18,7 +18,7 @@ describe('createGrayscaleAdjustment', () => {
|
|
|
18
18
|
|
|
19
19
|
it('intensity 0 leaves color unchanged', () => {
|
|
20
20
|
const adjustment = createGrayscaleAdjustment({ intensity: 0 });
|
|
21
|
-
expect(applyColorMatrixToColor(adjustment.colorMatrix
|
|
21
|
+
expect(applyColorMatrixToColor(adjustment.colorMatrix, 0x2040a0ff)).toBe(0x2040a0ff);
|
|
22
22
|
});
|
|
23
23
|
});
|
|
24
24
|
describe('initializeGrayscaleAdjustment', () => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createHueSaturationAdjustment, initializeHueSaturationAdjustment } from './hueSaturationAdjustment';
|
|
1
|
+
import { createHueSaturationAdjustment, initializeHueSaturationAdjustment } from './hueSaturationAdjustment.ts';
|
|
2
2
|
|
|
3
3
|
describe('createHueSaturationAdjustment', () => {
|
|
4
4
|
it('defaults to the identity and carries a fusable transform', () => {
|