@flighthq/adjustments 0.1.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/dist/brightnessContrastAdjustment.d.ts +3 -0
- package/dist/brightnessContrastAdjustment.d.ts.map +1 -0
- package/dist/brightnessContrastAdjustment.js +22 -0
- package/dist/brightnessContrastAdjustment.js.map +1 -0
- package/dist/channelMixerAdjustment.d.ts +3 -0
- package/dist/channelMixerAdjustment.d.ts.map +1 -0
- package/dist/channelMixerAdjustment.js +16 -0
- package/dist/channelMixerAdjustment.js.map +1 -0
- package/dist/colorAdjustmentResolution.d.ts +7 -0
- package/dist/colorAdjustmentResolution.d.ts.map +1 -0
- package/dist/colorAdjustmentResolution.js +59 -0
- package/dist/colorAdjustmentResolution.js.map +1 -0
- package/dist/colorBlindSimulationAdjustment.d.ts +3 -0
- package/dist/colorBlindSimulationAdjustment.d.ts.map +1 -0
- package/dist/colorBlindSimulationAdjustment.js +33 -0
- package/dist/colorBlindSimulationAdjustment.js.map +1 -0
- package/dist/colorGradeAdjustment.d.ts +3 -0
- package/dist/colorGradeAdjustment.d.ts.map +1 -0
- package/dist/colorGradeAdjustment.js +49 -0
- package/dist/colorGradeAdjustment.js.map +1 -0
- package/dist/colorLut.d.ts +29 -0
- package/dist/colorLut.d.ts.map +1 -0
- package/dist/colorLut.js +87 -0
- package/dist/colorLut.js.map +1 -0
- package/dist/colorLutAdjustment.d.ts +8 -0
- package/dist/colorLutAdjustment.d.ts.map +1 -0
- package/dist/colorLutAdjustment.js +30 -0
- package/dist/colorLutAdjustment.js.map +1 -0
- package/dist/colorLutCache.d.ts +6 -0
- package/dist/colorLutCache.d.ts.map +1 -0
- package/dist/colorLutCache.js +43 -0
- package/dist/colorLutCache.js.map +1 -0
- package/dist/colorMatrixAdjustment.d.ts +8 -0
- package/dist/colorMatrixAdjustment.d.ts.map +1 -0
- package/dist/colorMatrixAdjustment.js +14 -0
- package/dist/colorMatrixAdjustment.js.map +1 -0
- package/dist/colorMatrixMath.d.ts +160 -0
- package/dist/colorMatrixMath.d.ts.map +1 -0
- package/dist/colorMatrixMath.js +398 -0
- package/dist/colorMatrixMath.js.map +1 -0
- package/dist/colorTransformAdjustment.d.ts +3 -0
- package/dist/colorTransformAdjustment.d.ts.map +1 -0
- package/dist/colorTransformAdjustment.js +16 -0
- package/dist/colorTransformAdjustment.js.map +1 -0
- package/dist/exposureAdjustment.d.ts +3 -0
- package/dist/exposureAdjustment.d.ts.map +1 -0
- package/dist/exposureAdjustment.js +18 -0
- package/dist/exposureAdjustment.js.map +1 -0
- package/dist/grayscaleAdjustment.d.ts +3 -0
- package/dist/grayscaleAdjustment.d.ts.map +1 -0
- package/dist/grayscaleAdjustment.js +20 -0
- package/dist/grayscaleAdjustment.js.map +1 -0
- package/dist/hueSaturationAdjustment.d.ts +3 -0
- package/dist/hueSaturationAdjustment.d.ts.map +1 -0
- package/dist/hueSaturationAdjustment.js +62 -0
- package/dist/hueSaturationAdjustment.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/invertAdjustment.d.ts +3 -0
- package/dist/invertAdjustment.d.ts.map +1 -0
- package/dist/invertAdjustment.js +17 -0
- package/dist/invertAdjustment.js.map +1 -0
- package/dist/liftGammaGainAdjustment.d.ts +3 -0
- package/dist/liftGammaGainAdjustment.d.ts.map +1 -0
- package/dist/liftGammaGainAdjustment.js +29 -0
- package/dist/liftGammaGainAdjustment.js.map +1 -0
- package/dist/lookupTableGradeAdjustment.d.ts +3 -0
- package/dist/lookupTableGradeAdjustment.d.ts.map +1 -0
- package/dist/lookupTableGradeAdjustment.js +24 -0
- package/dist/lookupTableGradeAdjustment.js.map +1 -0
- package/dist/sepiaAdjustment.d.ts +3 -0
- package/dist/sepiaAdjustment.d.ts.map +1 -0
- package/dist/sepiaAdjustment.js +15 -0
- package/dist/sepiaAdjustment.js.map +1 -0
- package/package.json +37 -0
- package/src/brightnessContrastAdjustment.test.ts +23 -0
- package/src/channelMixerAdjustment.test.ts +24 -0
- package/src/colorAdjustmentResolution.test.ts +77 -0
- package/src/colorBlindSimulationAdjustment.test.ts +27 -0
- package/src/colorGradeAdjustment.test.ts +36 -0
- package/src/colorLut.test.ts +62 -0
- package/src/colorLutAdjustment.test.ts +37 -0
- package/src/colorLutCache.test.ts +61 -0
- package/src/colorMatrixAdjustment.test.ts +24 -0
- package/src/colorMatrixMath.test.ts +431 -0
- package/src/colorTransformAdjustment.test.ts +40 -0
- package/src/exposureAdjustment.test.ts +22 -0
- package/src/grayscaleAdjustment.test.ts +23 -0
- package/src/hueSaturationAdjustment.test.ts +33 -0
- package/src/invertAdjustment.test.ts +24 -0
- package/src/liftGammaGainAdjustment.test.ts +31 -0
- package/src/lookupTableGradeAdjustment.test.ts +49 -0
- package/src/sepiaAdjustment.test.ts +18 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Color-matrix math: preset builders, combinators, and evaluation for 4×5 RGBA color matrices.
|
|
3
|
+
*
|
|
4
|
+
* A color-matrix is a 4×5 affine transform applied to premultiplied RGBA color vectors:
|
|
5
|
+
* | R' | | m0 m1 m2 m3 m4 | | R |
|
|
6
|
+
* | G' | = | m5 m6 m7 m8 m9 | × | G |
|
|
7
|
+
* | B' | | m10 m11 m12 m13 m14 | | B |
|
|
8
|
+
* | A' | | m15 m16 m17 m18 m19 | | A |
|
|
9
|
+
* | 1 |
|
|
10
|
+
*
|
|
11
|
+
* Row 0 = R output coefficients (R, G, B, A inputs, then R offset).
|
|
12
|
+
* Row 1 = G output coefficients.
|
|
13
|
+
* Row 2 = B output coefficients.
|
|
14
|
+
* Row 3 = A output coefficients.
|
|
15
|
+
*
|
|
16
|
+
* The offset column (indices 4, 9, 14, 19) is in the range 0..255 (Flash convention).
|
|
17
|
+
*/
|
|
18
|
+
/** Required length of a valid color-matrix array. */
|
|
19
|
+
export declare const COLOR_MATRIX_LENGTH = 20;
|
|
20
|
+
/**
|
|
21
|
+
* Evaluates `matrix` against a packed `0xRRGGBBAA` color. Useful for previews and tests; pure
|
|
22
|
+
* math, no surface operations. Offsets are in the Flash 0–255 range; result is clamped to 0–255
|
|
23
|
+
* per channel and repacked as `0xRRGGBBAA`.
|
|
24
|
+
*/
|
|
25
|
+
export declare function applyColorMatrixToColor(matrix: Readonly<number[]>, packedRgba: number): number;
|
|
26
|
+
/**
|
|
27
|
+
* Composes `source` into `target` in place: `target = target × source` (applies source first,
|
|
28
|
+
* then target). Matches OpenFL color-matrix `concat` semantics. Alias-safe: `source` may be
|
|
29
|
+
* `target`.
|
|
30
|
+
*/
|
|
31
|
+
export declare function concatColorMatrix(target: number[], source: Readonly<number[]>): void;
|
|
32
|
+
/**
|
|
33
|
+
* Returns a color matrix that adds `amount` to the brightness offset of each channel. Positive
|
|
34
|
+
* `amount` brightens; negative darkens. `amount` is in the Flash 0–255 offset range. Allocates a
|
|
35
|
+
* new array.
|
|
36
|
+
*/
|
|
37
|
+
export declare function createBrightnessColorMatrix(amount: number): number[];
|
|
38
|
+
/**
|
|
39
|
+
* Returns a channel-mixer color matrix. Each `[r, g, b]` triple defines the source mix for the
|
|
40
|
+
* corresponding output channel. Values are in the 0–1 range (1 = full contribution). Allocates a
|
|
41
|
+
* new array.
|
|
42
|
+
*
|
|
43
|
+
* Example: `createChannelMixerColorMatrix([1, 0, 0], [0, 1, 0], [0, 0, 1])` is the identity.
|
|
44
|
+
* Swapping channels: `createChannelMixerColorMatrix([0, 1, 0], [1, 0, 0], [0, 0, 1])` swaps R/G.
|
|
45
|
+
*/
|
|
46
|
+
export declare function createChannelMixerColorMatrix(redOut: Readonly<[number, number, number]>, greenOut: Readonly<[number, number, number]>, blueOut: Readonly<[number, number, number]>): number[];
|
|
47
|
+
/**
|
|
48
|
+
* Returns a color balance matrix that independently shifts highlights, midtones, and shadows.
|
|
49
|
+
* Each parameter is a `[red, green, blue]` offset in the –100..100 range (Flash-style, mapped to
|
|
50
|
+
* –255..255 offsets). Allocates a new array.
|
|
51
|
+
*
|
|
52
|
+
* Implementation uses a three-range additive model: shadows affect dark pixels (luma < 85),
|
|
53
|
+
* highlights affect bright pixels (luma > 170), and midtones are weighted by proximity to the
|
|
54
|
+
* centre luma value. Because colour matrices cannot represent luma-gating directly, the offsets
|
|
55
|
+
* are applied uniformly and weighted by the fraction of the range each band covers; for precise
|
|
56
|
+
* per-band clamping use a LUT-based approach in `filters-surface`.
|
|
57
|
+
*/
|
|
58
|
+
export declare function createColorBalanceColorMatrix(shadows: Readonly<[number, number, number]>, midtones: Readonly<[number, number, number]>, highlights: Readonly<[number, number, number]>): number[];
|
|
59
|
+
/**
|
|
60
|
+
* Returns a color matrix that tints toward `packedRgba` (0xRRGGBBAA) by `amount` (0 = original,
|
|
61
|
+
* 1 = solid tint color). Allocates a new array.
|
|
62
|
+
*/
|
|
63
|
+
export declare function createColorMatrixFromTint(packedRgba: number, amount: number): number[];
|
|
64
|
+
/**
|
|
65
|
+
* Returns a color matrix that scales contrast by `amount` (1 = original, 0 = flat mid-grey, >1 =
|
|
66
|
+
* increased contrast). Allocates a new array.
|
|
67
|
+
*/
|
|
68
|
+
export declare function createContrastColorMatrix(amount: number): number[];
|
|
69
|
+
/**
|
|
70
|
+
* Returns a color matrix that desaturates by `amount` (0 = no change, 1 = fully desaturated /
|
|
71
|
+
* grayscale). Allocates a new array. Equivalent to `createSaturationColorMatrix(1 - amount)`.
|
|
72
|
+
*/
|
|
73
|
+
export declare function createDesaturateColorMatrix(amount: number): number[];
|
|
74
|
+
/**
|
|
75
|
+
* Returns a grayscale color matrix using luma-weighted ITU-R BT.601 coefficients
|
|
76
|
+
* (R=0.299, G=0.587, B=0.114). Allocates a new array.
|
|
77
|
+
*/
|
|
78
|
+
export declare function createGrayscaleColorMatrix(): number[];
|
|
79
|
+
/**
|
|
80
|
+
* Returns a hue-rotation color matrix that rotates the hue wheel by `degrees`. Allocates a new
|
|
81
|
+
* array.
|
|
82
|
+
*/
|
|
83
|
+
export declare function createHueRotateColorMatrix(degrees: number): number[];
|
|
84
|
+
/**
|
|
85
|
+
* Returns the identity color matrix. Applying it leaves colors unchanged.
|
|
86
|
+
* Allocates a new array.
|
|
87
|
+
*/
|
|
88
|
+
export declare function createIdentityColorMatrix(): number[];
|
|
89
|
+
/**
|
|
90
|
+
* Returns an invert color matrix that produces `255 - channel` per RGB channel. Alpha is
|
|
91
|
+
* unchanged. Allocates a new array.
|
|
92
|
+
*/
|
|
93
|
+
export declare function createInvertColorMatrix(): number[];
|
|
94
|
+
/**
|
|
95
|
+
* Returns a levels color matrix that remaps the input range `[inBlack, inWhite]` to the output
|
|
96
|
+
* range `[outBlack, outWhite]` with optional `gamma` correction. All values are in 0–255. `gamma`
|
|
97
|
+
* defaults to 1 (linear). Allocates a new array.
|
|
98
|
+
*
|
|
99
|
+
* The remapping function is:
|
|
100
|
+
* output = outBlack + (outWhite - outBlack) * ((input - inBlack) / (inWhite - inBlack))^(1/gamma)
|
|
101
|
+
* Because colour matrices cannot represent a true power-law curve, `gamma` is approximated via a
|
|
102
|
+
* linear scale-and-offset that matches the midpoint of the gamma curve; for exact gamma correction
|
|
103
|
+
* apply a LUT in `filters-surface`.
|
|
104
|
+
*/
|
|
105
|
+
export declare function createLevelsColorMatrix(inBlack: number, inWhite: number, outBlack: number, outWhite: number, gamma?: number): number[];
|
|
106
|
+
/**
|
|
107
|
+
* Returns a color matrix that scales the alpha channel by `alpha` (0 = transparent, 1 = opaque).
|
|
108
|
+
* RGB channels are unchanged. Allocates a new array.
|
|
109
|
+
*/
|
|
110
|
+
export declare function createOpacityColorMatrix(alpha: number): number[];
|
|
111
|
+
/**
|
|
112
|
+
* Returns a color matrix that applies a Polaroid-style warm orange-tint look.
|
|
113
|
+
* Allocates a new array. This is a data constant exposed as a factory for
|
|
114
|
+
* consistent API shape with the other presets.
|
|
115
|
+
*/
|
|
116
|
+
export declare function createPolaroidColorMatrix(): number[];
|
|
117
|
+
/**
|
|
118
|
+
* Returns a color matrix that scales color saturation by `amount` (0 = grayscale, 1 = original,
|
|
119
|
+
* >1 = oversaturated). Allocates a new array.
|
|
120
|
+
*/
|
|
121
|
+
export declare function createSaturationColorMatrix(amount: number): number[];
|
|
122
|
+
/**
|
|
123
|
+
* Returns a sepia-tone color matrix. Allocates a new array.
|
|
124
|
+
*/
|
|
125
|
+
export declare function createSepiaColorMatrix(): number[];
|
|
126
|
+
/**
|
|
127
|
+
* Returns a color matrix approximating the Technicolor two-strip process: warm reds/oranges
|
|
128
|
+
* with cyan shadows and a slight green cross-process. Allocates a new array.
|
|
129
|
+
*/
|
|
130
|
+
export declare function createTechnicolorColorMatrix(): number[];
|
|
131
|
+
/**
|
|
132
|
+
* Returns a vintage/faded-film color matrix: desaturated, warm tones, lifted blacks.
|
|
133
|
+
* Allocates a new array.
|
|
134
|
+
*/
|
|
135
|
+
export declare function createVintageColorMatrix(): number[];
|
|
136
|
+
/**
|
|
137
|
+
* Returns a white-balance color matrix that adjusts color temperature toward warm (positive
|
|
138
|
+
* `temperature` values) or cool (negative) and tint toward green (positive `tint`) or magenta
|
|
139
|
+
* (negative). Both parameters are in the –100..100 range. Allocates a new array.
|
|
140
|
+
*
|
|
141
|
+
* Temperature shifts are modelled as complementary R/B channel gains (warm = more R, less B).
|
|
142
|
+
* Tint shifts are modelled as G channel gain (more G = green, less G = magenta). This matches the
|
|
143
|
+
* Lightroom/Camera Raw slider convention.
|
|
144
|
+
*/
|
|
145
|
+
export declare function createWhiteBalanceColorMatrix(temperature: number, tint: number): number[];
|
|
146
|
+
/**
|
|
147
|
+
* Fuses a run of color matrices into ONE matrix that applies them left-to-right (index 0 first, then
|
|
148
|
+
* 1, …). This is the matrix-tier fuse: a stack of consecutive matrix-tier adjustments collapses to a
|
|
149
|
+
* single 4×5 matrix run through one generic color-matrix pass instead of one pass per adjustment.
|
|
150
|
+
* Order matters (matrix composition is not commutative); an empty list yields the identity. Allocates
|
|
151
|
+
* the result array.
|
|
152
|
+
*/
|
|
153
|
+
export declare function fuseColorMatrices(matrices: ReadonlyArray<Readonly<number[]>>): number[];
|
|
154
|
+
/**
|
|
155
|
+
* Composes matrix `b` applied first and then `a`. The result is equivalent to applying `b` to a
|
|
156
|
+
* color and then `a` to the result. When `out` is provided the result is written there (alias-safe:
|
|
157
|
+
* `out` may be `a` or `b`). Returns the output array (either `out` or a freshly allocated array).
|
|
158
|
+
*/
|
|
159
|
+
export declare function multiplyColorMatrix(a: Readonly<number[]>, b: Readonly<number[]>, out?: number[]): number[];
|
|
160
|
+
//# sourceMappingURL=colorMatrixMath.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colorMatrixMath.d.ts","sourceRoot":"","sources":["../src/colorMatrixMath.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,qDAAqD;AACrD,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAEtC;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAU9F;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,CAEpF;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAQpE;AAED;;;;;;;GAOG;AACH,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,QAAQ,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,EAC1C,QAAQ,EAAE,QAAQ,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,EAC5C,OAAO,EAAE,QAAQ,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,GAC1C,MAAM,EAAE,CA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,MAAM,GAAG,MAAM,EAAE,CAWpE;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,EAAE,CASjD;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,IAAI,MAAM,EAAE,CASvD;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,IAAI,MAAM,EAAE,CAQnD;AAED;;;;;;;;GAQG;AACH,wBAAgB,6BAA6B,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAezF;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,aAAa,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,MAAM,EAAE,CAKvF;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAoE1G"}
|
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Color-matrix math: preset builders, combinators, and evaluation for 4×5 RGBA color matrices.
|
|
3
|
+
*
|
|
4
|
+
* A color-matrix is a 4×5 affine transform applied to premultiplied RGBA color vectors:
|
|
5
|
+
* | R' | | m0 m1 m2 m3 m4 | | R |
|
|
6
|
+
* | G' | = | m5 m6 m7 m8 m9 | × | G |
|
|
7
|
+
* | B' | | m10 m11 m12 m13 m14 | | B |
|
|
8
|
+
* | A' | | m15 m16 m17 m18 m19 | | A |
|
|
9
|
+
* | 1 |
|
|
10
|
+
*
|
|
11
|
+
* Row 0 = R output coefficients (R, G, B, A inputs, then R offset).
|
|
12
|
+
* Row 1 = G output coefficients.
|
|
13
|
+
* Row 2 = B output coefficients.
|
|
14
|
+
* Row 3 = A output coefficients.
|
|
15
|
+
*
|
|
16
|
+
* The offset column (indices 4, 9, 14, 19) is in the range 0..255 (Flash convention).
|
|
17
|
+
*/
|
|
18
|
+
/** Required length of a valid color-matrix array. */
|
|
19
|
+
export const COLOR_MATRIX_LENGTH = 20;
|
|
20
|
+
/**
|
|
21
|
+
* Evaluates `matrix` against a packed `0xRRGGBBAA` color. Useful for previews and tests; pure
|
|
22
|
+
* math, no surface operations. Offsets are in the Flash 0–255 range; result is clamped to 0–255
|
|
23
|
+
* per channel and repacked as `0xRRGGBBAA`.
|
|
24
|
+
*/
|
|
25
|
+
export function applyColorMatrixToColor(matrix, packedRgba) {
|
|
26
|
+
const r = (packedRgba >>> 24) & 0xff;
|
|
27
|
+
const g = (packedRgba >>> 16) & 0xff;
|
|
28
|
+
const b = (packedRgba >>> 8) & 0xff;
|
|
29
|
+
const a = packedRgba & 0xff;
|
|
30
|
+
const rOut = clampByte(matrix[0] * r + matrix[1] * g + matrix[2] * b + matrix[3] * a + matrix[4]);
|
|
31
|
+
const gOut = clampByte(matrix[5] * r + matrix[6] * g + matrix[7] * b + matrix[8] * a + matrix[9]);
|
|
32
|
+
const bOut = clampByte(matrix[10] * r + matrix[11] * g + matrix[12] * b + matrix[13] * a + matrix[14]);
|
|
33
|
+
const aOut = clampByte(matrix[15] * r + matrix[16] * g + matrix[17] * b + matrix[18] * a + matrix[19]);
|
|
34
|
+
return ((rOut << 24) | (gOut << 16) | (bOut << 8) | aOut) >>> 0;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Composes `source` into `target` in place: `target = target × source` (applies source first,
|
|
38
|
+
* then target). Matches OpenFL color-matrix `concat` semantics. Alias-safe: `source` may be
|
|
39
|
+
* `target`.
|
|
40
|
+
*/
|
|
41
|
+
export function concatColorMatrix(target, source) {
|
|
42
|
+
multiplyColorMatrix(target, source, target);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Returns a color matrix that adds `amount` to the brightness offset of each channel. Positive
|
|
46
|
+
* `amount` brightens; negative darkens. `amount` is in the Flash 0–255 offset range. Allocates a
|
|
47
|
+
* new array.
|
|
48
|
+
*/
|
|
49
|
+
export function createBrightnessColorMatrix(amount) {
|
|
50
|
+
// prettier-ignore
|
|
51
|
+
return [
|
|
52
|
+
1, 0, 0, 0, amount,
|
|
53
|
+
0, 1, 0, 0, amount,
|
|
54
|
+
0, 0, 1, 0, amount,
|
|
55
|
+
0, 0, 0, 1, 0,
|
|
56
|
+
];
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Returns a channel-mixer color matrix. Each `[r, g, b]` triple defines the source mix for the
|
|
60
|
+
* corresponding output channel. Values are in the 0–1 range (1 = full contribution). Allocates a
|
|
61
|
+
* new array.
|
|
62
|
+
*
|
|
63
|
+
* Example: `createChannelMixerColorMatrix([1, 0, 0], [0, 1, 0], [0, 0, 1])` is the identity.
|
|
64
|
+
* Swapping channels: `createChannelMixerColorMatrix([0, 1, 0], [1, 0, 0], [0, 0, 1])` swaps R/G.
|
|
65
|
+
*/
|
|
66
|
+
export function createChannelMixerColorMatrix(redOut, greenOut, blueOut) {
|
|
67
|
+
// prettier-ignore
|
|
68
|
+
return [
|
|
69
|
+
redOut[0], redOut[1], redOut[2], 0, 0,
|
|
70
|
+
greenOut[0], greenOut[1], greenOut[2], 0, 0,
|
|
71
|
+
blueOut[0], blueOut[1], blueOut[2], 0, 0,
|
|
72
|
+
0, 0, 0, 1, 0,
|
|
73
|
+
];
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Returns a color balance matrix that independently shifts highlights, midtones, and shadows.
|
|
77
|
+
* Each parameter is a `[red, green, blue]` offset in the –100..100 range (Flash-style, mapped to
|
|
78
|
+
* –255..255 offsets). Allocates a new array.
|
|
79
|
+
*
|
|
80
|
+
* Implementation uses a three-range additive model: shadows affect dark pixels (luma < 85),
|
|
81
|
+
* highlights affect bright pixels (luma > 170), and midtones are weighted by proximity to the
|
|
82
|
+
* centre luma value. Because colour matrices cannot represent luma-gating directly, the offsets
|
|
83
|
+
* are applied uniformly and weighted by the fraction of the range each band covers; for precise
|
|
84
|
+
* per-band clamping use a LUT-based approach in `filters-surface`.
|
|
85
|
+
*/
|
|
86
|
+
export function createColorBalanceColorMatrix(shadows, midtones, highlights) {
|
|
87
|
+
// Map each band's [-100,100] range to Flash offsets [-255,255] and weight by band contribution.
|
|
88
|
+
// Shadows weight 0.25, midtones 0.5, highlights 0.25 — ensures the total offset range matches
|
|
89
|
+
// a single-band full swing without clipping the combined result beyond ±255.
|
|
90
|
+
const scale = 255 / 100;
|
|
91
|
+
const rOff = (shadows[0] * 0.25 + midtones[0] * 0.5 + highlights[0] * 0.25) * scale;
|
|
92
|
+
const gOff = (shadows[1] * 0.25 + midtones[1] * 0.5 + highlights[1] * 0.25) * scale;
|
|
93
|
+
const bOff = (shadows[2] * 0.25 + midtones[2] * 0.5 + highlights[2] * 0.25) * scale;
|
|
94
|
+
// prettier-ignore
|
|
95
|
+
return [
|
|
96
|
+
1, 0, 0, 0, rOff,
|
|
97
|
+
0, 1, 0, 0, gOff,
|
|
98
|
+
0, 0, 1, 0, bOff,
|
|
99
|
+
0, 0, 0, 1, 0,
|
|
100
|
+
];
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Returns a color matrix that tints toward `packedRgba` (0xRRGGBBAA) by `amount` (0 = original,
|
|
104
|
+
* 1 = solid tint color). Allocates a new array.
|
|
105
|
+
*/
|
|
106
|
+
export function createColorMatrixFromTint(packedRgba, amount) {
|
|
107
|
+
const tr = ((packedRgba >>> 24) & 0xff) * amount;
|
|
108
|
+
const tg = ((packedRgba >>> 16) & 0xff) * amount;
|
|
109
|
+
const tb = ((packedRgba >>> 8) & 0xff) * amount;
|
|
110
|
+
const keep = 1 - amount;
|
|
111
|
+
// prettier-ignore
|
|
112
|
+
return [
|
|
113
|
+
keep, 0, 0, 0, tr,
|
|
114
|
+
0, keep, 0, 0, tg,
|
|
115
|
+
0, 0, keep, 0, tb,
|
|
116
|
+
0, 0, 0, 1, 0,
|
|
117
|
+
];
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Returns a color matrix that scales contrast by `amount` (1 = original, 0 = flat mid-grey, >1 =
|
|
121
|
+
* increased contrast). Allocates a new array.
|
|
122
|
+
*/
|
|
123
|
+
export function createContrastColorMatrix(amount) {
|
|
124
|
+
// Translate to midpoint, scale, translate back: offset = 128 * (1 - amount).
|
|
125
|
+
const offset = 128 * (1 - amount);
|
|
126
|
+
// prettier-ignore
|
|
127
|
+
return [
|
|
128
|
+
amount, 0, 0, 0, offset,
|
|
129
|
+
0, amount, 0, 0, offset,
|
|
130
|
+
0, 0, amount, 0, offset,
|
|
131
|
+
0, 0, 0, 1, 0,
|
|
132
|
+
];
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Returns a color matrix that desaturates by `amount` (0 = no change, 1 = fully desaturated /
|
|
136
|
+
* grayscale). Allocates a new array. Equivalent to `createSaturationColorMatrix(1 - amount)`.
|
|
137
|
+
*/
|
|
138
|
+
export function createDesaturateColorMatrix(amount) {
|
|
139
|
+
return createSaturationColorMatrix(1 - amount);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Returns a grayscale color matrix using luma-weighted ITU-R BT.601 coefficients
|
|
143
|
+
* (R=0.299, G=0.587, B=0.114). Allocates a new array.
|
|
144
|
+
*/
|
|
145
|
+
export function createGrayscaleColorMatrix() {
|
|
146
|
+
const r = 0.299;
|
|
147
|
+
const g = 0.587;
|
|
148
|
+
const b = 0.114;
|
|
149
|
+
// prettier-ignore
|
|
150
|
+
return [
|
|
151
|
+
r, g, b, 0, 0,
|
|
152
|
+
r, g, b, 0, 0,
|
|
153
|
+
r, g, b, 0, 0,
|
|
154
|
+
0, 0, 0, 1, 0,
|
|
155
|
+
];
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Returns a hue-rotation color matrix that rotates the hue wheel by `degrees`. Allocates a new
|
|
159
|
+
* array.
|
|
160
|
+
*/
|
|
161
|
+
export function createHueRotateColorMatrix(degrees) {
|
|
162
|
+
const rad = (degrees * Math.PI) / 180;
|
|
163
|
+
const cos = Math.cos(rad);
|
|
164
|
+
const sin = Math.sin(rad);
|
|
165
|
+
// Hue rotation via the standard 3×3 rotation in a perceptual luminance-preserving basis.
|
|
166
|
+
const lumR = 0.213;
|
|
167
|
+
const lumG = 0.715;
|
|
168
|
+
const lumB = 0.072;
|
|
169
|
+
// prettier-ignore
|
|
170
|
+
return [
|
|
171
|
+
lumR + cos * (1 - lumR) + sin * -lumR, lumG + cos * -lumG + sin * -lumG, lumB + cos * -lumB + sin * (1 - lumB), 0, 0,
|
|
172
|
+
lumR + cos * -lumR + sin * 0.143, lumG + cos * (1 - lumG) + sin * 0.140, lumB + cos * -lumB + sin * -0.283, 0, 0,
|
|
173
|
+
lumR + cos * -lumR + sin * -(1 - lumR), lumG + cos * -lumG + sin * lumG, lumB + cos * (1 - lumB) + sin * lumB, 0, 0,
|
|
174
|
+
0, 0, 0, 1, 0,
|
|
175
|
+
];
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Returns the identity color matrix. Applying it leaves colors unchanged.
|
|
179
|
+
* Allocates a new array.
|
|
180
|
+
*/
|
|
181
|
+
export function createIdentityColorMatrix() {
|
|
182
|
+
// prettier-ignore
|
|
183
|
+
return [
|
|
184
|
+
1, 0, 0, 0, 0,
|
|
185
|
+
0, 1, 0, 0, 0,
|
|
186
|
+
0, 0, 1, 0, 0,
|
|
187
|
+
0, 0, 0, 1, 0,
|
|
188
|
+
];
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Returns an invert color matrix that produces `255 - channel` per RGB channel. Alpha is
|
|
192
|
+
* unchanged. Allocates a new array.
|
|
193
|
+
*/
|
|
194
|
+
export function createInvertColorMatrix() {
|
|
195
|
+
// prettier-ignore
|
|
196
|
+
return [
|
|
197
|
+
-1, 0, 0, 0, 255,
|
|
198
|
+
0, -1, 0, 0, 255,
|
|
199
|
+
0, 0, -1, 0, 255,
|
|
200
|
+
0, 0, 0, 1, 0,
|
|
201
|
+
];
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Returns a levels color matrix that remaps the input range `[inBlack, inWhite]` to the output
|
|
205
|
+
* range `[outBlack, outWhite]` with optional `gamma` correction. All values are in 0–255. `gamma`
|
|
206
|
+
* defaults to 1 (linear). Allocates a new array.
|
|
207
|
+
*
|
|
208
|
+
* The remapping function is:
|
|
209
|
+
* output = outBlack + (outWhite - outBlack) * ((input - inBlack) / (inWhite - inBlack))^(1/gamma)
|
|
210
|
+
* Because colour matrices cannot represent a true power-law curve, `gamma` is approximated via a
|
|
211
|
+
* linear scale-and-offset that matches the midpoint of the gamma curve; for exact gamma correction
|
|
212
|
+
* apply a LUT in `filters-surface`.
|
|
213
|
+
*/
|
|
214
|
+
export function createLevelsColorMatrix(inBlack, inWhite, outBlack, outWhite, gamma = 1) {
|
|
215
|
+
// Guard against degenerate input range.
|
|
216
|
+
const inRange = inWhite - inBlack;
|
|
217
|
+
const scale = inRange === 0 ? 1 : (outWhite - outBlack) / inRange;
|
|
218
|
+
// Linear-midpoint gamma approximation: a slope correction factor at the midpoint.
|
|
219
|
+
const gammaCorrectedScale = scale * (gamma === 1 ? 1 : Math.pow(0.5, 1 / gamma - 1));
|
|
220
|
+
const offset = outBlack - inBlack * gammaCorrectedScale;
|
|
221
|
+
// prettier-ignore
|
|
222
|
+
return [
|
|
223
|
+
gammaCorrectedScale, 0, 0, 0, offset,
|
|
224
|
+
0, gammaCorrectedScale, 0, 0, offset,
|
|
225
|
+
0, 0, gammaCorrectedScale, 0, offset,
|
|
226
|
+
0, 0, 0, 1, 0,
|
|
227
|
+
];
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Returns a color matrix that scales the alpha channel by `alpha` (0 = transparent, 1 = opaque).
|
|
231
|
+
* RGB channels are unchanged. Allocates a new array.
|
|
232
|
+
*/
|
|
233
|
+
export function createOpacityColorMatrix(alpha) {
|
|
234
|
+
// prettier-ignore
|
|
235
|
+
return [
|
|
236
|
+
1, 0, 0, 0, 0,
|
|
237
|
+
0, 1, 0, 0, 0,
|
|
238
|
+
0, 0, 1, 0, 0,
|
|
239
|
+
0, 0, 0, alpha, 0,
|
|
240
|
+
];
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Returns a color matrix that applies a Polaroid-style warm orange-tint look.
|
|
244
|
+
* Allocates a new array. This is a data constant exposed as a factory for
|
|
245
|
+
* consistent API shape with the other presets.
|
|
246
|
+
*/
|
|
247
|
+
export function createPolaroidColorMatrix() {
|
|
248
|
+
// Warm highlight, slightly desaturated mid-tones, lifted blacks.
|
|
249
|
+
// prettier-ignore
|
|
250
|
+
return [
|
|
251
|
+
1.438, -0.062, -0.062, 0, -31.8,
|
|
252
|
+
-0.122, 1.378, -0.122, 0, 16.2,
|
|
253
|
+
-0.016, -0.016, 1.484, 0, -47.6,
|
|
254
|
+
0, 0, 0, 1, 0,
|
|
255
|
+
];
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Returns a color matrix that scales color saturation by `amount` (0 = grayscale, 1 = original,
|
|
259
|
+
* >1 = oversaturated). Allocates a new array.
|
|
260
|
+
*/
|
|
261
|
+
export function createSaturationColorMatrix(amount) {
|
|
262
|
+
const r = 0.299 * (1 - amount);
|
|
263
|
+
const g = 0.587 * (1 - amount);
|
|
264
|
+
const b = 0.114 * (1 - amount);
|
|
265
|
+
// prettier-ignore
|
|
266
|
+
return [
|
|
267
|
+
r + amount, g, b, 0, 0,
|
|
268
|
+
r, g + amount, b, 0, 0,
|
|
269
|
+
r, g, b + amount, 0, 0,
|
|
270
|
+
0, 0, 0, 1, 0,
|
|
271
|
+
];
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Returns a sepia-tone color matrix. Allocates a new array.
|
|
275
|
+
*/
|
|
276
|
+
export function createSepiaColorMatrix() {
|
|
277
|
+
// Standard sepia values widely used in CSS/Flash.
|
|
278
|
+
// prettier-ignore
|
|
279
|
+
return [
|
|
280
|
+
0.393, 0.769, 0.189, 0, 0,
|
|
281
|
+
0.349, 0.686, 0.168, 0, 0,
|
|
282
|
+
0.272, 0.534, 0.131, 0, 0,
|
|
283
|
+
0, 0, 0, 1, 0,
|
|
284
|
+
];
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Returns a color matrix approximating the Technicolor two-strip process: warm reds/oranges
|
|
288
|
+
* with cyan shadows and a slight green cross-process. Allocates a new array.
|
|
289
|
+
*/
|
|
290
|
+
export function createTechnicolorColorMatrix() {
|
|
291
|
+
// Derived from the classic Technicolor look formula widely cited in colour grading literature.
|
|
292
|
+
// prettier-ignore
|
|
293
|
+
return [
|
|
294
|
+
1.9126, -0.8, -0.09, 0, 11.79,
|
|
295
|
+
-0.2, 1.7, -0.27, 0, -14.69,
|
|
296
|
+
-0.14, -0.21, 1.62, 0, -3.38,
|
|
297
|
+
0, 0, 0, 1, 0,
|
|
298
|
+
];
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Returns a vintage/faded-film color matrix: desaturated, warm tones, lifted blacks.
|
|
302
|
+
* Allocates a new array.
|
|
303
|
+
*/
|
|
304
|
+
export function createVintageColorMatrix() {
|
|
305
|
+
// prettier-ignore
|
|
306
|
+
return [
|
|
307
|
+
0.9, 0.05, 0.05, 0, 10,
|
|
308
|
+
0.0, 0.85, 0.0, 0, 5,
|
|
309
|
+
0.0, 0.0, 0.75, 0, 0,
|
|
310
|
+
0, 0, 0, 1, 0,
|
|
311
|
+
];
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Returns a white-balance color matrix that adjusts color temperature toward warm (positive
|
|
315
|
+
* `temperature` values) or cool (negative) and tint toward green (positive `tint`) or magenta
|
|
316
|
+
* (negative). Both parameters are in the –100..100 range. Allocates a new array.
|
|
317
|
+
*
|
|
318
|
+
* Temperature shifts are modelled as complementary R/B channel gains (warm = more R, less B).
|
|
319
|
+
* Tint shifts are modelled as G channel gain (more G = green, less G = magenta). This matches the
|
|
320
|
+
* Lightroom/Camera Raw slider convention.
|
|
321
|
+
*/
|
|
322
|
+
export function createWhiteBalanceColorMatrix(temperature, tint) {
|
|
323
|
+
// Map [-100, 100] to multiplicative gain adjustments centred at 1.
|
|
324
|
+
// Max temperature shift = ±0.3 gain on R/B; max tint shift = ±0.15 gain on G.
|
|
325
|
+
const tempScale = temperature / 100;
|
|
326
|
+
const tintScale = tint / 100;
|
|
327
|
+
const rGain = 1 + tempScale * 0.3;
|
|
328
|
+
const gGain = 1 + tintScale * 0.15;
|
|
329
|
+
const bGain = 1 - tempScale * 0.3;
|
|
330
|
+
// prettier-ignore
|
|
331
|
+
return [
|
|
332
|
+
rGain, 0, 0, 0, 0,
|
|
333
|
+
0, gGain, 0, 0, 0,
|
|
334
|
+
0, 0, bGain, 0, 0,
|
|
335
|
+
0, 0, 0, 1, 0,
|
|
336
|
+
];
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Fuses a run of color matrices into ONE matrix that applies them left-to-right (index 0 first, then
|
|
340
|
+
* 1, …). This is the matrix-tier fuse: a stack of consecutive matrix-tier adjustments collapses to a
|
|
341
|
+
* single 4×5 matrix run through one generic color-matrix pass instead of one pass per adjustment.
|
|
342
|
+
* Order matters (matrix composition is not commutative); an empty list yields the identity. Allocates
|
|
343
|
+
* the result array.
|
|
344
|
+
*/
|
|
345
|
+
export function fuseColorMatrices(matrices) {
|
|
346
|
+
if (matrices.length === 0)
|
|
347
|
+
return createIdentityColorMatrix();
|
|
348
|
+
const out = matrices[0].slice();
|
|
349
|
+
for (let i = 1; i < matrices.length; i++)
|
|
350
|
+
multiplyColorMatrix(matrices[i], out, out);
|
|
351
|
+
return out;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Composes matrix `b` applied first and then `a`. The result is equivalent to applying `b` to a
|
|
355
|
+
* color and then `a` to the result. When `out` is provided the result is written there (alias-safe:
|
|
356
|
+
* `out` may be `a` or `b`). Returns the output array (either `out` or a freshly allocated array).
|
|
357
|
+
*/
|
|
358
|
+
export function multiplyColorMatrix(a, b, out) {
|
|
359
|
+
// Read all inputs into locals before writing to `out` (alias-safe).
|
|
360
|
+
const a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4];
|
|
361
|
+
const a5 = a[5], a6 = a[6], a7 = a[7], a8 = a[8], a9 = a[9];
|
|
362
|
+
const a10 = a[10], a11 = a[11], a12 = a[12], a13 = a[13], a14 = a[14];
|
|
363
|
+
const a15 = a[15], a16 = a[16], a17 = a[17], a18 = a[18], a19 = a[19];
|
|
364
|
+
const b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4];
|
|
365
|
+
const b5 = b[5], b6 = b[6], b7 = b[7], b8 = b[8], b9 = b[9];
|
|
366
|
+
const b10 = b[10], b11 = b[11], b12 = b[12], b13 = b[13], b14 = b[14];
|
|
367
|
+
const b15 = b[15], b16 = b[16], b17 = b[17], b18 = b[18], b19 = b[19];
|
|
368
|
+
const result = out ?? new Array(20);
|
|
369
|
+
// Row 0 (R output)
|
|
370
|
+
result[0] = a0 * b0 + a1 * b5 + a2 * b10 + a3 * b15;
|
|
371
|
+
result[1] = a0 * b1 + a1 * b6 + a2 * b11 + a3 * b16;
|
|
372
|
+
result[2] = a0 * b2 + a1 * b7 + a2 * b12 + a3 * b17;
|
|
373
|
+
result[3] = a0 * b3 + a1 * b8 + a2 * b13 + a3 * b18;
|
|
374
|
+
result[4] = a0 * b4 + a1 * b9 + a2 * b14 + a3 * b19 + a4;
|
|
375
|
+
// Row 1 (G output)
|
|
376
|
+
result[5] = a5 * b0 + a6 * b5 + a7 * b10 + a8 * b15;
|
|
377
|
+
result[6] = a5 * b1 + a6 * b6 + a7 * b11 + a8 * b16;
|
|
378
|
+
result[7] = a5 * b2 + a6 * b7 + a7 * b12 + a8 * b17;
|
|
379
|
+
result[8] = a5 * b3 + a6 * b8 + a7 * b13 + a8 * b18;
|
|
380
|
+
result[9] = a5 * b4 + a6 * b9 + a7 * b14 + a8 * b19 + a9;
|
|
381
|
+
// Row 2 (B output)
|
|
382
|
+
result[10] = a10 * b0 + a11 * b5 + a12 * b10 + a13 * b15;
|
|
383
|
+
result[11] = a10 * b1 + a11 * b6 + a12 * b11 + a13 * b16;
|
|
384
|
+
result[12] = a10 * b2 + a11 * b7 + a12 * b12 + a13 * b17;
|
|
385
|
+
result[13] = a10 * b3 + a11 * b8 + a12 * b13 + a13 * b18;
|
|
386
|
+
result[14] = a10 * b4 + a11 * b9 + a12 * b14 + a13 * b19 + a14;
|
|
387
|
+
// Row 3 (A output)
|
|
388
|
+
result[15] = a15 * b0 + a16 * b5 + a17 * b10 + a18 * b15;
|
|
389
|
+
result[16] = a15 * b1 + a16 * b6 + a17 * b11 + a18 * b16;
|
|
390
|
+
result[17] = a15 * b2 + a16 * b7 + a17 * b12 + a18 * b17;
|
|
391
|
+
result[18] = a15 * b3 + a16 * b8 + a17 * b13 + a18 * b18;
|
|
392
|
+
result[19] = a15 * b4 + a16 * b9 + a17 * b14 + a18 * b19 + a19;
|
|
393
|
+
return result;
|
|
394
|
+
}
|
|
395
|
+
function clampByte(v) {
|
|
396
|
+
return Math.max(0, Math.min(255, Math.round(v)));
|
|
397
|
+
}
|
|
398
|
+
//# sourceMappingURL=colorMatrixMath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colorMatrixMath.js","sourceRoot":"","sources":["../src/colorMatrixMath.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,qDAAqD;AACrD,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAEtC;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,MAA0B,EAAE,UAAkB;IACpF,MAAM,CAAC,GAAG,CAAC,UAAU,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IACrC,MAAM,CAAC,GAAG,CAAC,UAAU,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IACrC,MAAM,CAAC,GAA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IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colorTransformAdjustment.d.ts","sourceRoot":"","sources":["../src/colorTransformAdjustment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAOhF,wBAAgB,8BAA8B,CAAC,cAAc,EAAE,QAAQ,CAAC,cAAc,CAAC,GAAG,wBAAwB,CASjH"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// The node-level color transform as a matrix-tier adjustment — the first member of a node's generic
|
|
2
|
+
// color-adjustment stack. It keeps the 8-field `ColorTransform` payload and bakes it into a
|
|
3
|
+
// diagonal-affine 4×5 `colorMatrix` (offset column in the 0–255 convention, matching colorMatrixMath) so
|
|
4
|
+
// it fuses with other matrix-tier adjustments; the inline fold reads the ColorTransform payload back (or,
|
|
5
|
+
// for a multi-op stack, the fused matrix resolved to an affine ColorTransform).
|
|
6
|
+
export function createColorTransformAdjustment(colorTransform) {
|
|
7
|
+
// prettier-ignore
|
|
8
|
+
const colorMatrix = [
|
|
9
|
+
colorTransform.redMultiplier, 0, 0, 0, colorTransform.redOffset,
|
|
10
|
+
0, colorTransform.greenMultiplier, 0, 0, colorTransform.greenOffset,
|
|
11
|
+
0, 0, colorTransform.blueMultiplier, 0, colorTransform.blueOffset,
|
|
12
|
+
0, 0, 0, colorTransform.alphaMultiplier, colorTransform.alphaOffset,
|
|
13
|
+
];
|
|
14
|
+
return { kind: 'ColorTransformAdjustment', colorTransform: colorTransform, colorMatrix };
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=colorTransformAdjustment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colorTransformAdjustment.js","sourceRoot":"","sources":["../src/colorTransformAdjustment.ts"],"names":[],"mappings":"AAEA,oGAAoG;AACpG,4FAA4F;AAC5F,yGAAyG;AACzG,0GAA0G;AAC1G,gFAAgF;AAChF,MAAM,UAAU,8BAA8B,CAAC,cAAwC;IACrF,kBAAkB;IAClB,MAAM,WAAW,GAAG;QAClB,cAAc,CAAC,aAAa,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,cAAc,CAAC,SAAS;QAC/D,CAAC,EAAE,cAAc,CAAC,eAAe,EAAE,CAAC,EAAE,CAAC,EAAE,cAAc,CAAC,WAAW;QACnE,CAAC,EAAE,CAAC,EAAE,cAAc,CAAC,cAAc,EAAE,CAAC,EAAE,cAAc,CAAC,UAAU;QACjE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,cAAc,CAAC,eAAe,EAAE,cAAc,CAAC,WAAW;KACpE,CAAC;IACF,OAAO,EAAE,IAAI,EAAE,0BAA0B,EAAE,cAAc,EAAE,cAAgC,EAAE,WAAW,EAAE,CAAC;AAC7G,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exposureAdjustment.d.ts","sourceRoot":"","sources":["../src/exposureAdjustment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAQ1D,wBAAgB,wBAAwB,CACtC,OAAO,GAAE,QAAQ,CAAC,IAAI,CAAC,kBAAkB,EAAE,MAAM,GAAG,aAAa,CAAC,CAAM,GACvE,kBAAkB,CAUpB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Linear exposure as a matrix-tier adjustment: RGB is scaled by `2^exposure` (a per-channel diagonal
|
|
2
|
+
// multiply, no offset), reproducing the prior full-frame `rgb·2^exposure` shader. Alpha is unchanged.
|
|
3
|
+
// The default rgba8 pipeline clamps the result to [0,1] (matching the fused color-matrix pass's clamp),
|
|
4
|
+
// so this is the correct SDR exposure. An unclamped/HDR exposure variant (values >1 into a float target)
|
|
5
|
+
// is a future add — it cannot fold through the clamping color-matrix pass and would be its own realization.
|
|
6
|
+
// Default exposure 0 is the identity.
|
|
7
|
+
export function createExposureAdjustment(options = {}) {
|
|
8
|
+
const m = Math.pow(2, options.exposure ?? 0);
|
|
9
|
+
// prettier-ignore
|
|
10
|
+
const colorMatrix = [
|
|
11
|
+
m, 0, 0, 0, 0,
|
|
12
|
+
0, m, 0, 0, 0,
|
|
13
|
+
0, 0, m, 0, 0,
|
|
14
|
+
0, 0, 0, 1, 0,
|
|
15
|
+
];
|
|
16
|
+
return { kind: 'ExposureAdjustment', ...options, colorMatrix };
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=exposureAdjustment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exposureAdjustment.js","sourceRoot":"","sources":["../src/exposureAdjustment.ts"],"names":[],"mappings":"AAEA,qGAAqG;AACrG,sGAAsG;AACtG,wGAAwG;AACxG,yGAAyG;AACzG,4GAA4G;AAC5G,sCAAsC;AACtC,MAAM,UAAU,wBAAwB,CACtC,UAAsE,EAAE;IAExE,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,QAAQ,IAAI,CAAC,CAAC,CAAC;IAC7C,kBAAkB;IAClB,MAAM,WAAW,GAAG;QAClB,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;QACb,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;QACb,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;QACb,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;KACd,CAAC;IACF,OAAO,EAAE,IAAI,EAAE,oBAAoB,EAAE,GAAG,OAAO,EAAE,WAAW,EAAE,CAAC;AACjE,CAAC"}
|