@flighthq/adjustments 0.2.1-next.841.373388f → 0.3.0-next.1032.e2b99fc

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.
Files changed (76) hide show
  1. package/dist/brightnessContrastAdjustment.d.ts +1 -1
  2. package/dist/brightnessContrastAdjustment.d.ts.map +1 -1
  3. package/dist/brightnessContrastAdjustment.js +3 -3
  4. package/dist/brightnessContrastAdjustment.js.map +1 -1
  5. package/dist/channelMixerAdjustment.d.ts +1 -1
  6. package/dist/channelMixerAdjustment.d.ts.map +1 -1
  7. package/dist/channelMixerAdjustment.js +5 -5
  8. package/dist/channelMixerAdjustment.js.map +1 -1
  9. package/dist/colorAdjustmentResolution.d.ts +3 -2
  10. package/dist/colorAdjustmentResolution.d.ts.map +1 -1
  11. package/dist/colorAdjustmentResolution.js +33 -18
  12. package/dist/colorAdjustmentResolution.js.map +1 -1
  13. package/dist/colorBlindSimulationAdjustment.d.ts +1 -1
  14. package/dist/colorBlindSimulationAdjustment.d.ts.map +1 -1
  15. package/dist/colorGradeAdjustment.d.ts +1 -1
  16. package/dist/colorGradeAdjustment.d.ts.map +1 -1
  17. package/dist/colorLut.d.ts +1 -1
  18. package/dist/colorLut.d.ts.map +1 -1
  19. package/dist/colorLutAdjustment.d.ts +1 -1
  20. package/dist/colorLutAdjustment.d.ts.map +1 -1
  21. package/dist/colorLutAdjustment.js +4 -4
  22. package/dist/colorLutAdjustment.js.map +1 -1
  23. package/dist/colorLutCache.d.ts +1 -1
  24. package/dist/colorLutCache.d.ts.map +1 -1
  25. package/dist/colorMatrixAdjustment.d.ts +2 -1
  26. package/dist/colorMatrixAdjustment.d.ts.map +1 -1
  27. package/dist/colorMatrixAdjustment.js +6 -0
  28. package/dist/colorMatrixAdjustment.js.map +1 -1
  29. package/dist/colorMatrixMath.d.ts +8 -9
  30. package/dist/colorMatrixMath.d.ts.map +1 -1
  31. package/dist/colorMatrixMath.js +36 -37
  32. package/dist/colorMatrixMath.js.map +1 -1
  33. package/dist/colorScaleBiasAdjustment.d.ts +3 -0
  34. package/dist/colorScaleBiasAdjustment.d.ts.map +1 -0
  35. package/dist/colorScaleBiasAdjustment.js +30 -0
  36. package/dist/colorScaleBiasAdjustment.js.map +1 -0
  37. package/dist/contract.d.ts +20 -0
  38. package/dist/contract.d.ts.map +1 -0
  39. package/dist/contract.js +20 -0
  40. package/dist/contract.js.map +1 -0
  41. package/dist/exposureAdjustment.d.ts +1 -1
  42. package/dist/exposureAdjustment.d.ts.map +1 -1
  43. package/dist/grayscaleAdjustment.d.ts +1 -1
  44. package/dist/grayscaleAdjustment.d.ts.map +1 -1
  45. package/dist/hueSaturationAdjustment.d.ts +1 -1
  46. package/dist/hueSaturationAdjustment.d.ts.map +1 -1
  47. package/dist/index.d.ts +1 -18
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +1 -18
  50. package/dist/index.js.map +1 -1
  51. package/dist/invertAdjustment.d.ts +1 -1
  52. package/dist/invertAdjustment.d.ts.map +1 -1
  53. package/dist/invertAdjustment.js +3 -3
  54. package/dist/invertAdjustment.js.map +1 -1
  55. package/dist/liftGammaGainAdjustment.d.ts +1 -1
  56. package/dist/liftGammaGainAdjustment.d.ts.map +1 -1
  57. package/dist/lookupTableGradeAdjustment.d.ts +1 -1
  58. package/dist/lookupTableGradeAdjustment.d.ts.map +1 -1
  59. package/dist/sepiaAdjustment.d.ts +1 -1
  60. package/dist/sepiaAdjustment.d.ts.map +1 -1
  61. package/dist/tintAdjustment.d.ts +3 -0
  62. package/dist/tintAdjustment.d.ts.map +1 -0
  63. package/dist/tintAdjustment.js +19 -0
  64. package/dist/tintAdjustment.js.map +1 -0
  65. package/package.json +6 -2
  66. package/src/colorAdjustmentResolution.test.ts +49 -37
  67. package/src/colorLut.test.ts +1 -1
  68. package/src/colorMatrixAdjustment.test.ts +16 -2
  69. package/src/colorMatrixMath.test.ts +9 -9
  70. package/src/colorScaleBiasAdjustment.test.ts +21 -0
  71. package/src/tintAdjustment.test.ts +31 -0
  72. package/dist/colorTransformAdjustment.d.ts +0 -3
  73. package/dist/colorTransformAdjustment.d.ts.map +0 -1
  74. package/dist/colorTransformAdjustment.js +0 -16
  75. package/dist/colorTransformAdjustment.js.map +0 -1
  76. package/src/colorTransformAdjustment.test.ts +0 -40
@@ -1,3 +1,3 @@
1
- import type { BrightnessContrastAdjustment } from '@flighthq/types';
1
+ import type { BrightnessContrastAdjustment } from '@flighthq/types/contract';
2
2
  export declare function createBrightnessContrastAdjustment(options?: Readonly<Omit<BrightnessContrastAdjustment, 'kind' | 'colorMatrix'>>): BrightnessContrastAdjustment;
3
3
  //# sourceMappingURL=brightnessContrastAdjustment.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"brightnessContrastAdjustment.d.ts","sourceRoot":"","sources":["../src/brightnessContrastAdjustment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AASpE,wBAAgB,kCAAkC,CAChD,OAAO,GAAE,QAAQ,CAAC,IAAI,CAAC,4BAA4B,EAAE,MAAM,GAAG,aAAa,CAAC,CAAM,GACjF,4BAA4B,CAa9B"}
1
+ {"version":3,"file":"brightnessContrastAdjustment.d.ts","sourceRoot":"","sources":["../src/brightnessContrastAdjustment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AAS7E,wBAAgB,kCAAkC,CAChD,OAAO,GAAE,QAAQ,CAAC,IAAI,CAAC,4BAA4B,EAAE,MAAM,GAAG,aAAa,CAAC,CAAM,GACjF,4BAA4B,CAa9B"}
@@ -1,15 +1,15 @@
1
1
  // Brightness/contrast as a matrix-tier adjustment. Reproduces the prior full-frame shader
2
2
  // `rgb = (rgb + brightness − 0.5)·contrast + 0.5` (a shift by brightness, then scale about mid-grey 0.5).
3
3
  // Expanded, that is affine per channel: `rgb·contrast + (brightness·contrast + 0.5·(1 − contrast))`, so the
4
- // matrix is scale `contrast`, normalized offset `brightness·contrast + 0.5·(1 − contrast)` (×255 for the
5
- // 0–255 offset column). Alpha is unchanged. Identity defaults are brightness 0, contrast 1 (the prior
4
+ // matrix is scale `contrast`, normalized bias `brightness·contrast + 0.5·(1 − contrast)`.
5
+ // Alpha is unchanged. Identity defaults are brightness 0, contrast 1 (the prior
6
6
  // `renderEffectDefaults` listed `contrast: 0`, which disagreed with the shader's `contrast ?? 1` identity —
7
7
  // this corrects it to contrast 1).
8
8
  export function createBrightnessContrastAdjustment(options = {}) {
9
9
  const brightness = options.brightness ?? 0;
10
10
  const contrast = options.contrast ?? 1;
11
11
  const s = contrast;
12
- const o = 255 * (brightness * contrast + 0.5 * (1 - contrast));
12
+ const o = brightness * contrast + 0.5 * (1 - contrast);
13
13
  // prettier-ignore
14
14
  const colorMatrix = [
15
15
  s, 0, 0, 0, o,
@@ -1 +1 @@
1
- {"version":3,"file":"brightnessContrastAdjustment.js","sourceRoot":"","sources":["../src/brightnessContrastAdjustment.ts"],"names":[],"mappings":"AAEA,0FAA0F;AAC1F,0GAA0G;AAC1G,4GAA4G;AAC5G,yGAAyG;AACzG,sGAAsG;AACtG,4GAA4G;AAC5G,mCAAmC;AACnC,MAAM,UAAU,kCAAkC,CAChD,UAAgF,EAAE;IAElF,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,CAAC,CAAC;IAC3C,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,CAAC,CAAC;IACvC,MAAM,CAAC,GAAG,QAAQ,CAAC;IACnB,MAAM,CAAC,GAAG,GAAG,GAAG,CAAC,UAAU,GAAG,QAAQ,GAAG,GAAG,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;IAC/D,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,8BAA8B,EAAE,GAAG,OAAO,EAAE,WAAW,EAAE,CAAC;AAC3E,CAAC"}
1
+ {"version":3,"file":"brightnessContrastAdjustment.js","sourceRoot":"","sources":["../src/brightnessContrastAdjustment.ts"],"names":[],"mappings":"AAEA,0FAA0F;AAC1F,0GAA0G;AAC1G,4GAA4G;AAC5G,0FAA0F;AAC1F,gFAAgF;AAChF,4GAA4G;AAC5G,mCAAmC;AACnC,MAAM,UAAU,kCAAkC,CAChD,UAAgF,EAAE;IAElF,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,CAAC,CAAC;IAC3C,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,CAAC,CAAC;IACvC,MAAM,CAAC,GAAG,QAAQ,CAAC;IACnB,MAAM,CAAC,GAAG,UAAU,GAAG,QAAQ,GAAG,GAAG,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC;IACvD,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,8BAA8B,EAAE,GAAG,OAAO,EAAE,WAAW,EAAE,CAAC;AAC3E,CAAC"}
@@ -1,3 +1,3 @@
1
- import type { ChannelMixerAdjustment } from '@flighthq/types';
1
+ import type { ChannelMixerAdjustment } from '@flighthq/types/contract';
2
2
  export declare function createChannelMixerAdjustment(options?: Readonly<Omit<ChannelMixerAdjustment, 'kind' | 'colorMatrix'>>): ChannelMixerAdjustment;
3
3
  //# sourceMappingURL=channelMixerAdjustment.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"channelMixerAdjustment.d.ts","sourceRoot":"","sources":["../src/channelMixerAdjustment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAQ9D,wBAAgB,4BAA4B,CAC1C,OAAO,GAAE,QAAQ,CAAC,IAAI,CAAC,sBAAsB,EAAE,MAAM,GAAG,aAAa,CAAC,CAAsC,GAC3G,sBAAsB,CAQxB"}
1
+ {"version":3,"file":"channelMixerAdjustment.d.ts","sourceRoot":"","sources":["../src/channelMixerAdjustment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAQvE,wBAAgB,4BAA4B,CAC1C,OAAO,GAAE,QAAQ,CAAC,IAAI,CAAC,sBAAsB,EAAE,MAAM,GAAG,aAAa,CAAC,CAAsC,GAC3G,sBAAsB,CAQxB"}
@@ -1,15 +1,15 @@
1
1
  import { createChannelMixerColorMatrix } from './colorMatrixMath';
2
2
  // Channel mixer as a matrix-tier adjustment. `matrix` is the prior effect's 3×4 row-major RGB→RGB mix
3
- // plus a per-row offset (offsets in normalized 0–1). The 3×3 mix bakes through createChannelMixerColorMatrix;
4
- // the offset column is scaled to the 0–255 color-matrix convention (×255). Alpha is unchanged. The default
3
+ // plus a per-row normalized-linear bias. The 3×3 mix bakes through createChannelMixerColorMatrix;
4
+ // the bias column uses the same units without conversion. Alpha is unchanged. The default
5
5
  // `matrix` is the identity mix.
6
6
  export function createChannelMixerAdjustment(options = { matrix: IDENTITY_CHANNEL_MIXER }) {
7
7
  const matrix = options.matrix ?? IDENTITY_CHANNEL_MIXER;
8
8
  const m = (i) => matrix[i] ?? IDENTITY_CHANNEL_MIXER[i];
9
9
  const colorMatrix = createChannelMixerColorMatrix([m(0), m(1), m(2)], [m(4), m(5), m(6)], [m(8), m(9), m(10)]);
10
- colorMatrix[4] = m(3) * 255;
11
- colorMatrix[9] = m(7) * 255;
12
- colorMatrix[14] = m(11) * 255;
10
+ colorMatrix[4] = m(3);
11
+ colorMatrix[9] = m(7);
12
+ colorMatrix[14] = m(11);
13
13
  return { kind: 'ChannelMixerAdjustment', ...options, matrix, colorMatrix };
14
14
  }
15
15
  const IDENTITY_CHANNEL_MIXER = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0];
@@ -1 +1 @@
1
- {"version":3,"file":"channelMixerAdjustment.js","sourceRoot":"","sources":["../src/channelMixerAdjustment.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAElE,sGAAsG;AACtG,8GAA8G;AAC9G,2GAA2G;AAC3G,gCAAgC;AAChC,MAAM,UAAU,4BAA4B,CAC1C,UAA0E,EAAE,MAAM,EAAE,sBAAsB,EAAE;IAE5G,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,sBAAsB,CAAC;IACxD,MAAM,CAAC,GAAG,CAAC,CAAS,EAAU,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,sBAAsB,CAAC,CAAC,CAAC,CAAC;IACxE,MAAM,WAAW,GAAG,6BAA6B,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC/G,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAA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AE,CAAC,CAAC,CAAC,CAAC;IAC/G,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACtB,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACtB,WAAW,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;IACxB,OAAO,EAAE,IAAI,EAAE,wBAAwB,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;AAC7E,CAAC;AAED,MAAM,sBAAsB,GAAsB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC"}
@@ -1,7 +1,8 @@
1
- import type { Adjustment, ColorTransform } from '@flighthq/types';
1
+ import type { Adjustment, ColorScaleBias } from '@flighthq/types/contract';
2
2
  export declare const COLOR_ADJUSTMENT_NONE = 0;
3
3
  export declare const COLOR_ADJUSTMENT_AFFINE = 1;
4
4
  export declare const COLOR_ADJUSTMENT_CHANNEL_MIXING = 2;
5
5
  export declare function isAffineColorMatrix(matrix: Readonly<number[]>): boolean;
6
- export declare function resolveColorAdjustmentsColorTransform(adjustments: readonly Adjustment[] | null, out: ColorTransform): number;
6
+ export declare function resolveColorAdjustmentsColorMatrix(adjustments: readonly Adjustment[] | null): number[] | null;
7
+ export declare function resolveColorAdjustmentsColorScaleBias(adjustments: readonly Adjustment[] | null, out: ColorScaleBias): number;
7
8
  //# sourceMappingURL=colorAdjustmentResolution.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"colorAdjustmentResolution.d.ts","sourceRoot":"","sources":["../src/colorAdjustmentResolution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAMlE,eAAO,MAAM,qBAAqB,IAAI,CAAC;AACvC,eAAO,MAAM,uBAAuB,IAAI,CAAC;AACzC,eAAO,MAAM,+BAA+B,IAAI,CAAC;AAKjD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC,GAAG,OAAO,CAevE;AAcD,wBAAgB,qCAAqC,CACnD,WAAW,EAAE,SAAS,UAAU,EAAE,GAAG,IAAI,EACzC,GAAG,EAAE,cAAc,GAClB,MAAM,CAsBR"}
1
+ {"version":3,"file":"colorAdjustmentResolution.d.ts","sourceRoot":"","sources":["../src/colorAdjustmentResolution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAM3E,eAAO,MAAM,qBAAqB,IAAI,CAAC;AACvC,eAAO,MAAM,uBAAuB,IAAI,CAAC;AACzC,eAAO,MAAM,+BAA+B,IAAI,CAAC;AAMjD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC,GAAG,OAAO,CAevE;AAID,wBAAgB,kCAAkC,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,GAAG,IAAI,GAAG,MAAM,EAAE,GAAG,IAAI,CAS7G;AAcD,wBAAgB,qCAAqC,CACnD,WAAW,EAAE,SAAS,UAAU,EAAE,GAAG,IAAI,EACzC,GAAG,EAAE,cAAc,GAClB,MAAM,CAsBR"}
@@ -2,11 +2,12 @@ import { getAdjustmentColorMatrix } from './colorMatrixAdjustment';
2
2
  import { fuseColorMatrices } from './colorMatrixMath';
3
3
  // Resolution status of a node's color-adjustment stack against the affine inline fold.
4
4
  export const COLOR_ADJUSTMENT_NONE = 0; // empty stack — no tint (leave `out` untouched, use null)
5
- export const COLOR_ADJUSTMENT_AFFINE = 1; // fully representable as one 8-float ColorTransform
6
- export const COLOR_ADJUSTMENT_CHANNEL_MIXING = 2; // off-diagonal terms present — `out` holds only the affine part
7
- // True when `matrix` has no off-diagonal RGB/A coefficients, i.e. it is a per-channel scale + offset that
8
- // an 8-float ColorTransform can represent exactly. A diagonal-affine matrix is `[m0,·,·,·,off, ·,m6,·,·,off,
9
- // ·,·,m12,·,off, ·,·,·,m18,off]`. Fusing diagonal matrices stays diagonal, so this stays an exact zero check.
5
+ export const COLOR_ADJUSTMENT_AFFINE = 1; // fully representable as one 8-float ColorScaleBias
6
+ export const COLOR_ADJUSTMENT_CHANNEL_MIXING = 2; // a full matrix or unsupported non-matrix op is present
7
+ // True when `matrix` has no off-diagonal RGB/A coefficients, i.e. it is a per-channel scale + bias that
8
+ // an 8-float ColorScaleBias can represent exactly. A diagonal-affine matrix is `[m0,·,·,·,bias, ·,m6,·,·,
9
+ // bias, ·,·,m12,·,bias, ·,·,·,m18,bias]`. Fusing diagonal matrices stays diagonal, so this stays an exact
10
+ // zero check.
10
11
  export function isAffineColorMatrix(matrix) {
11
12
  return (matrix[1] === 0 &&
12
13
  matrix[2] === 0 &&
@@ -21,19 +22,33 @@ export function isAffineColorMatrix(matrix) {
21
22
  matrix[16] === 0 &&
22
23
  matrix[17] === 0);
23
24
  }
24
- // Fuses a node's color-adjustment stack into the single affine `ColorTransform` the inline fold consumes,
25
- // writing per-channel multiply + 0–255 offset into `out`, and returns the resolution status:
25
+ // Resolves a stack to its complete fused 4×5 matrix when every member is matrix-tier. Returns null
26
+ // for an empty stack or when a non-matrix operation (for example a LUT) prevents exact inline fusion.
27
+ export function resolveColorAdjustmentsColorMatrix(adjustments) {
28
+ if (adjustments === null || adjustments.length === 0)
29
+ return null;
30
+ const matrices = [];
31
+ for (let i = 0; i < adjustments.length; i++) {
32
+ const matrix = getAdjustmentColorMatrix(adjustments[i]);
33
+ if (matrix === null)
34
+ return null;
35
+ matrices.push(matrix);
36
+ }
37
+ return fuseColorMatrices(matrices);
38
+ }
39
+ // Fuses a node's color-adjustment stack into the single affine `ColorScaleBias` the inline fold consumes,
40
+ // writing per-channel scale + normalized-linear bias into `out`, and returns the resolution status:
26
41
  //
27
42
  // COLOR_ADJUSTMENT_NONE — empty/null stack; `out` untouched (the caller uses null → no tint).
28
43
  // COLOR_ADJUSTMENT_AFFINE — the fused stack is diagonal-affine; `out` is exact.
29
44
  // COLOR_ADJUSTMENT_CHANNEL_MIXING — the fused matrix carries off-diagonal channel-mixing terms
30
45
  // (saturation/hue/sepia/channelMixer) or a non-matrix (LUT) op that the
31
46
  // 8-float fold cannot represent yet. `out` holds only the affine part
32
- // (diagonal + offset); the caller routes this to the deferral guard.
47
+ // (diagonal + bias); the caller can resolve the complete matrix.
33
48
  //
34
- // A single ColorTransformAdjustment (the common per-object case) resolves exactly with no matrix multiply.
49
+ // A single TintAdjustment or generic affine color matrix resolves through the same fused matrix path.
35
50
  // Matrix-tier ops fuse order-preserving via concatColorMatrix; a non-matrix op marks the stack non-affine.
36
- export function resolveColorAdjustmentsColorTransform(adjustments, out) {
51
+ export function resolveColorAdjustmentsColorScaleBias(adjustments, out) {
37
52
  if (adjustments === null || adjustments.length === 0)
38
53
  return COLOR_ADJUSTMENT_NONE;
39
54
  const matrices = [];
@@ -46,14 +61,14 @@ export function resolveColorAdjustmentsColorTransform(adjustments, out) {
46
61
  matrices.push(matrix);
47
62
  }
48
63
  const fused = fuseColorMatrices(matrices);
49
- out.redMultiplier = fused[0];
50
- out.greenMultiplier = fused[6];
51
- out.blueMultiplier = fused[12];
52
- out.alphaMultiplier = fused[18];
53
- out.redOffset = fused[4];
54
- out.greenOffset = fused[9];
55
- out.blueOffset = fused[14];
56
- out.alphaOffset = fused[19];
64
+ out.redScale = fused[0];
65
+ out.greenScale = fused[6];
66
+ out.blueScale = fused[12];
67
+ out.alphaScale = fused[18];
68
+ out.redBias = fused[4];
69
+ out.greenBias = fused[9];
70
+ out.blueBias = fused[14];
71
+ out.alphaBias = fused[19];
57
72
  return inlineable && isAffineColorMatrix(fused) ? COLOR_ADJUSTMENT_AFFINE : COLOR_ADJUSTMENT_CHANNEL_MIXING;
58
73
  }
59
74
  //# sourceMappingURL=colorAdjustmentResolution.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"colorAdjustmentResolution.js","sourceRoot":"","sources":["../src/colorAdjustmentResolution.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,uFAAuF;AACvF,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,CAAC,0DAA0D;AAClG,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,CAAC,oDAAoD;AAC9F,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAAC,CAAC,CAAC,gEAAgE;AAElH,0GAA0G;AAC1G,6GAA6G;AAC7G,8GAA8G;AAC9G,MAAM,UAAU,mBAAmB,CAAC,MAA0B;IAC5D,OAAO,CACL,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC;QACf,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC;QACf,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC;QACf,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC;QACf,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC;QACf,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC;QACf,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC;QAChB,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC;QAChB,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC;QAChB,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC;QAChB,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC;QAChB,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CACjB,CAAC;AACJ,CAAC;AAED,0GAA0G;AAC1G,6FAA6F;AAC7F,EAAE;AACF,0GAA0G;AAC1G,0FAA0F;AAC1F,iGAAiG;AACjG,4GAA4G;AAC5G,0GAA0G;AAC1G,yGAAyG;AACzG,EAAE;AACF,2GAA2G;AAC3G,2GAA2G;AAC3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,EAAE,CAAC,CAAC;IAC1B,GAAG,CAAC,UAAU,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC;IAC3B,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IACvB,GAAG,CAAC,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IACzB,GAAG,CAAC,QAAQ,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC;IACzB,GAAG,CAAC,SAAS,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC;IAE1B,OAAO,UAAU,IAAI,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,+BAA+B,CAAC;AAC9G,CAAC"}
@@ -1,3 +1,3 @@
1
- import type { ColorBlindSimulationAdjustment } from '@flighthq/types';
1
+ import type { ColorBlindSimulationAdjustment } from '@flighthq/types/contract';
2
2
  export declare function createColorBlindSimulationAdjustment(options?: Readonly<Omit<ColorBlindSimulationAdjustment, 'kind' | 'colorMatrix'>>): ColorBlindSimulationAdjustment;
3
3
  //# sourceMappingURL=colorBlindSimulationAdjustment.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"colorBlindSimulationAdjustment.d.ts","sourceRoot":"","sources":["../src/colorBlindSimulationAdjustment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,8BAA8B,EAAkB,MAAM,iBAAiB,CAAC;AAWtF,wBAAgB,oCAAoC,CAClD,OAAO,GAAE,QAAQ,CAAC,IAAI,CAAC,8BAA8B,EAAE,MAAM,GAAG,aAAa,CAAC,CAAM,GACnF,8BAA8B,CAWhC"}
1
+ {"version":3,"file":"colorBlindSimulationAdjustment.d.ts","sourceRoot":"","sources":["../src/colorBlindSimulationAdjustment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,8BAA8B,EAAkB,MAAM,0BAA0B,CAAC;AAW/F,wBAAgB,oCAAoC,CAClD,OAAO,GAAE,QAAQ,CAAC,IAAI,CAAC,8BAA8B,EAAE,MAAM,GAAG,aAAa,CAAC,CAAM,GACnF,8BAA8B,CAWhC"}
@@ -1,3 +1,3 @@
1
- import type { ColorGradeAdjustment } from '@flighthq/types';
1
+ import type { ColorGradeAdjustment } from '@flighthq/types/contract';
2
2
  export declare function createColorGradeAdjustment(options?: Readonly<Omit<ColorGradeAdjustment, 'kind' | 'transform'>>): ColorGradeAdjustment;
3
3
  //# sourceMappingURL=colorGradeAdjustment.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"colorGradeAdjustment.d.ts","sourceRoot":"","sources":["../src/colorGradeAdjustment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAA0B,MAAM,iBAAiB,CAAC;AAQpF,wBAAgB,0BAA0B,CACxC,OAAO,GAAE,QAAQ,CAAC,IAAI,CAAC,oBAAoB,EAAE,MAAM,GAAG,WAAW,CAAC,CAAM,GACvE,oBAAoB,CAmCtB"}
1
+ {"version":3,"file":"colorGradeAdjustment.d.ts","sourceRoot":"","sources":["../src/colorGradeAdjustment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAA0B,MAAM,0BAA0B,CAAC;AAQ7F,wBAAgB,0BAA0B,CACxC,OAAO,GAAE,QAAQ,CAAC,IAAI,CAAC,oBAAoB,EAAE,MAAM,GAAG,WAAW,CAAC,CAAM,GACvE,oBAAoB,CAmCtB"}
@@ -1,4 +1,4 @@
1
- import type { ColorLut, ColorTransformFunction } from '@flighthq/types';
1
+ import type { ColorLut, ColorTransformFunction } from '@flighthq/types/contract';
2
2
  /**
3
3
  * Baked-LUT math: compose a stack of pointwise rgb→rgb transforms into ONE 3D color lookup table, and
4
4
  * sample it. This is the LUT-tier fuse (the sibling of colorMatrixMath's `fuseColorMatrices`): where a
@@ -1 +1 @@
1
- {"version":3,"file":"colorLut.d.ts","sourceRoot":"","sources":["../src/colorLut.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAExE;;;;;;;;;;GAUG;AAEH,4GAA4G;AAC5G,eAAO,MAAM,sBAAsB,KAAK,CAAC;AAEzC;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,UAAU,EAAE,aAAa,CAAC,sBAAsB,CAAC,EACjD,IAAI,GAAE,MAA+B,GACpC,QAAQ,CAsBV;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,QAAQ,CAAC,QAAQ,CAAC,EACvB,GAAG,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAC7B,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,GACR,IAAI,CAiCN"}
1
+ {"version":3,"file":"colorLut.d.ts","sourceRoot":"","sources":["../src/colorLut.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAEjF;;;;;;;;;;GAUG;AAEH,4GAA4G;AAC5G,eAAO,MAAM,sBAAsB,KAAK,CAAC;AAEzC;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,UAAU,EAAE,aAAa,CAAC,sBAAsB,CAAC,EACjD,IAAI,GAAE,MAA+B,GACpC,QAAQ,CAsBV;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,QAAQ,CAAC,QAAQ,CAAC,EACvB,GAAG,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAC7B,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,GACR,IAAI,CAiCN"}
@@ -1,4 +1,4 @@
1
- import type { ColorLutAdjustment, ColorTransformFunction } from '@flighthq/types';
1
+ import type { ColorLutAdjustment, ColorTransformFunction } from '@flighthq/types/contract';
2
2
  export declare function getAdjustmentColorTransform(operation: Readonly<{
3
3
  kind: string;
4
4
  }>): ColorTransformFunction | null;
@@ -1 +1 @@
1
- {"version":3,"file":"colorLutAdjustment.d.ts","sourceRoot":"","sources":["../src/colorLutAdjustment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AASlF,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,QAAQ,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,sBAAsB,GAAG,IAAI,CAKhH;AAKD,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,QAAQ,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,SAAS,IAAI,kBAAkB,CAE3G"}
1
+ {"version":3,"file":"colorLutAdjustment.d.ts","sourceRoot":"","sources":["../src/colorLutAdjustment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAS3F,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,QAAQ,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,sBAAsB,GAAG,IAAI,CAKhH;AAKD,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,QAAQ,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,SAAS,IAAI,kBAAkB,CAE3G"}
@@ -17,14 +17,14 @@ export function getAdjustmentColorTransform(operation) {
17
17
  export function isColorLutAdjustment(operation) {
18
18
  return typeof operation.transform === 'function';
19
19
  }
20
- // Wraps a 4×5 color matrix (adjustments convention: linear RGBA coefficients + a 0–255 offset column) as
20
+ // Wraps a 4×5 color matrix (linear RGBA coefficients + normalized-linear bias column) as
21
21
  // an rgb→rgb transform on normalized color. Alpha is assumed opaque (1) — the LUT is a 3D rgb cube, so a
22
22
  // matrix's alpha→rgb coupling is not represented; pure color matrices (the common case) bake exactly.
23
23
  function colorMatrixTransform(m) {
24
24
  return (out, r, g, b) => {
25
- out[0] = m[0] * r + m[1] * g + m[2] * b + m[3] + m[4] / 255;
26
- out[1] = m[5] * r + m[6] * g + m[7] * b + m[8] + m[9] / 255;
27
- out[2] = m[10] * r + m[11] * g + m[12] * b + m[13] + m[14] / 255;
25
+ out[0] = m[0] * r + m[1] * g + m[2] * b + m[3] + m[4];
26
+ out[1] = m[5] * r + m[6] * g + m[7] * b + m[8] + m[9];
27
+ out[2] = m[10] * r + m[11] * g + m[12] * b + m[13] + m[14];
28
28
  };
29
29
  }
30
30
  //# sourceMappingURL=colorLutAdjustment.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"colorLutAdjustment.js","sourceRoot":"","sources":["../src/colorLutAdjustment.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAEnE,wGAAwG;AACxG,qGAAqG;AACrG,sGAAsG;AACtG,yGAAyG;AACzG,0DAA0D;AAC1D,MAAM,UAAU,2BAA2B,CAAC,SAAqC;IAC/E,MAAM,SAAS,GAAI,SAAmD,CAAC,SAAS,CAAC;IACjF,IAAI,OAAO,SAAS,KAAK,UAAU;QAAE,OAAO,SAAS,CAAC;IACtD,MAAM,MAAM,GAAG,wBAAwB,CAAC,SAAS,CAAC,CAAC;IACnD,OAAO,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;AAC/D,CAAC;AAED,kGAAkG;AAClG,yGAAyG;AACzG,0DAA0D;AAC1D,MAAM,UAAU,oBAAoB,CAAC,SAAqC;IACxE,OAAO,OAAQ,SAAmD,CAAC,SAAS,KAAK,UAAU,CAAC;AAC9F,CAAC;AAED,yGAAyG;AACzG,yGAAyG;AACzG,sGAAsG;AACtG,SAAS,oBAAoB,CAAC,CAAqB;IACjD,OAAO,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE;QACtB,GAAG,CA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CAAC,CAAC;AAC/D,CAAC;AAED,kGAAkG;AAClG,yGAAyG;AACzG,0DAA0D;AAC1D,MAAM,UAAU,oBAAoB,CAAC,SAAqC;IACxE,OAAO,OAAQ,SAAmD,CAAC,SAAS,KAAK,UAAU,CAAC;AAC9F,CAAC;AAED,yFAAyF;AACzF,yGAAyG;AACzG,sGAAsG;AACtG,SAAS,oBAAoB,CAAC,CAAqB;IACjD,OAAO,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE;QACtB,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACtD,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACtD,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;IAC7D,CAAC,CAAC;AACJ,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { ColorLut, ColorLutCache } from '@flighthq/types';
1
+ import type { ColorLut, ColorLutCache } from '@flighthq/types/contract';
2
2
  export declare function bakeColorLutForRun(cache: ColorLutCache, run: ReadonlyArray<Readonly<{
3
3
  kind: string;
4
4
  }>>, size?: number): ColorLut;
@@ -1 +1 @@
1
- {"version":3,"file":"colorLutCache.d.ts","sourceRoot":"","sources":["../src/colorLutCache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAA0B,MAAM,iBAAiB,CAAC;AAmBvF,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,aAAa,EACpB,GAAG,EAAE,aAAa,CAAC,QAAQ,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,EAC9C,IAAI,GAAE,MAA+B,GACpC,QAAQ,CAYV;AAID,wBAAgB,mBAAmB,IAAI,aAAa,CAEnD"}
1
+ {"version":3,"file":"colorLutCache.d.ts","sourceRoot":"","sources":["../src/colorLutCache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAA0B,MAAM,0BAA0B,CAAC;AAmBhG,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,aAAa,EACpB,GAAG,EAAE,aAAa,CAAC,QAAQ,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,EAC9C,IAAI,GAAE,MAA+B,GACpC,QAAQ,CAYV;AAID,wBAAgB,mBAAmB,IAAI,aAAa,CAEnD"}
@@ -1,4 +1,5 @@
1
- import type { ColorMatrixAdjustment } from '@flighthq/types';
1
+ import type { ColorMatrixAdjustment } from '@flighthq/types/contract';
2
+ export declare function createColorMatrixAdjustment(colorMatrix: readonly number[]): ColorMatrixAdjustment;
2
3
  export declare function getAdjustmentColorMatrix(operation: Readonly<{
3
4
  kind: string;
4
5
  }>): readonly number[] | null;
@@ -1 +1 @@
1
- {"version":3,"file":"colorMatrixAdjustment.d.ts","sourceRoot":"","sources":["../src/colorMatrixAdjustment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAQ7D,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,QAAQ,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,SAAS,MAAM,EAAE,GAAG,IAAI,CAGxG;AAGD,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,QAAQ,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,SAAS,IAAI,qBAAqB,CAEjH"}
1
+ {"version":3,"file":"colorMatrixAdjustment.d.ts","sourceRoot":"","sources":["../src/colorMatrixAdjustment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAItE,wBAAgB,2BAA2B,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,GAAG,qBAAqB,CAKjG;AAMD,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,QAAQ,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,SAAS,MAAM,EAAE,GAAG,IAAI,CAGxG;AAGD,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,QAAQ,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,SAAS,IAAI,qBAAqB,CAEjH"}
@@ -1,4 +1,10 @@
1
1
  import { COLOR_MATRIX_LENGTH } from './colorMatrixMath';
2
+ export function createColorMatrixAdjustment(colorMatrix) {
3
+ if (colorMatrix.length !== COLOR_MATRIX_LENGTH) {
4
+ throw new Error(`Color matrix must contain ${COLOR_MATRIX_LENGTH} values.`);
5
+ }
6
+ return { kind: 'ColorMatrixAdjustment', colorMatrix: [...colorMatrix] };
7
+ }
2
8
  // Returns the 4×5 color matrix a stack operation contributes to the fused matrix-tier pass, or null if
3
9
  // it is not a matrix-tier adjustment (a spatial/composite RenderEffect, or a LUT-tier adjustment). Lets
4
10
  // a pipeline recognise which stack entries fold into the single generic color-matrix pass without a
@@ -1 +1 @@
1
- {"version":3,"file":"colorMatrixAdjustment.js","sourceRoot":"","sources":["../src/colorMatrixAdjustment.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB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E,OAAO,wBAAwB,CAAC,SAAS,CAAC,KAAK,IAAI,CAAC;AACtD,CAAC"}
@@ -13,14 +13,14 @@
13
13
  * Row 2 = B output coefficients.
14
14
  * Row 3 = A output coefficients.
15
15
  *
16
- * The offset column (indices 4, 9, 14, 19) is in the range 0..255 (Flash convention).
16
+ * The bias column (indices 4, 9, 14, 19) uses normalized-linear, unbounded float units.
17
17
  */
18
18
  /** Required length of a valid color-matrix array. */
19
19
  export declare const COLOR_MATRIX_LENGTH = 20;
20
20
  /**
21
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`.
22
+ * math, no surface operations. Input bytes are normalized before applying the matrix; the result is
23
+ * clamped to 0–1 and repacked as `0xRRGGBBAA`.
24
24
  */
25
25
  export declare function applyColorMatrixToColor(matrix: Readonly<number[]>, packedRgba: number): number;
26
26
  /**
@@ -31,8 +31,7 @@ export declare function applyColorMatrixToColor(matrix: Readonly<number[]>, pack
31
31
  export declare function concatColorMatrix(target: number[], source: Readonly<number[]>): void;
32
32
  /**
33
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.
34
+ * `amount` brightens; negative darkens. `amount` is normalized-linear. Allocates a new array.
36
35
  */
37
36
  export declare function createBrightnessColorMatrix(amount: number): number[];
38
37
  /**
@@ -46,8 +45,8 @@ export declare function createBrightnessColorMatrix(amount: number): number[];
46
45
  export declare function createChannelMixerColorMatrix(redOut: Readonly<[number, number, number]>, greenOut: Readonly<[number, number, number]>, blueOut: Readonly<[number, number, number]>): number[];
47
46
  /**
48
47
  * 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.
48
+ * Each parameter is a `[red, green, blue]` offset in the –100..100 range, mapped to normalized
49
+ * –1..1 biases. Allocates a new array.
51
50
  *
52
51
  * Implementation uses a three-range additive model: shadows affect dark pixels (luma < 85),
53
52
  * highlights affect bright pixels (luma > 170), and midtones are weighted by proximity to the
@@ -87,13 +86,13 @@ export declare function createHueRotateColorMatrix(degrees: number): number[];
87
86
  */
88
87
  export declare function createIdentityColorMatrix(): number[];
89
88
  /**
90
- * Returns an invert color matrix that produces `255 - channel` per RGB channel. Alpha is
89
+ * Returns an invert color matrix that produces `1 - channel` per RGB channel. Alpha is
91
90
  * unchanged. Allocates a new array.
92
91
  */
93
92
  export declare function createInvertColorMatrix(): number[];
94
93
  /**
95
94
  * 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`
95
+ * range `[outBlack, outWhite]` with optional `gamma` correction. All values are normalized 0–1. `gamma`
97
96
  * defaults to 1 (linear). Allocates a new array.
98
97
  *
99
98
  * The remapping function is:
@@ -1 +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,QAA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 9, 14, 19) is in the range 0..255 (Flash convention).
16
+ * The bias column (indices 4, 9, 14, 19) uses normalized-linear, unbounded float units.
17
17
  */
18
18
  /** Required length of a valid color-matrix array. */
19
19
  export const COLOR_MATRIX_LENGTH = 20;
20
20
  /**
21
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`.
22
+ * math, no surface operations. Input bytes are normalized before applying the matrix; the result is
23
+ * clamped to 0–1 and repacked as `0xRRGGBBAA`.
24
24
  */
25
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]);
26
+ const r = ((packedRgba >>> 24) & 0xff) / 255;
27
+ const g = ((packedRgba >>> 16) & 0xff) / 255;
28
+ const b = ((packedRgba >>> 8) & 0xff) / 255;
29
+ const a = (packedRgba & 0xff) / 255;
30
+ const rOut = clampNormalizedByte(matrix[0] * r + matrix[1] * g + matrix[2] * b + matrix[3] * a + matrix[4]);
31
+ const gOut = clampNormalizedByte(matrix[5] * r + matrix[6] * g + matrix[7] * b + matrix[8] * a + matrix[9]);
32
+ const bOut = clampNormalizedByte(matrix[10] * r + matrix[11] * g + matrix[12] * b + matrix[13] * a + matrix[14]);
33
+ const aOut = clampNormalizedByte(matrix[15] * r + matrix[16] * g + matrix[17] * b + matrix[18] * a + matrix[19]);
34
34
  return ((rOut << 24) | (gOut << 16) | (bOut << 8) | aOut) >>> 0;
35
35
  }
36
36
  /**
@@ -43,8 +43,7 @@ export function concatColorMatrix(target, source) {
43
43
  }
44
44
  /**
45
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.
46
+ * `amount` brightens; negative darkens. `amount` is normalized-linear. Allocates a new array.
48
47
  */
49
48
  export function createBrightnessColorMatrix(amount) {
50
49
  // prettier-ignore
@@ -74,8 +73,8 @@ export function createChannelMixerColorMatrix(redOut, greenOut, blueOut) {
74
73
  }
75
74
  /**
76
75
  * 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.
76
+ * Each parameter is a `[red, green, blue]` offset in the –100..100 range, mapped to normalized
77
+ * –1..1 biases. Allocates a new array.
79
78
  *
80
79
  * Implementation uses a three-range additive model: shadows affect dark pixels (luma < 85),
81
80
  * highlights affect bright pixels (luma > 170), and midtones are weighted by proximity to the
@@ -84,10 +83,10 @@ export function createChannelMixerColorMatrix(redOut, greenOut, blueOut) {
84
83
  * per-band clamping use a LUT-based approach in `filters-surface`.
85
84
  */
86
85
  export function createColorBalanceColorMatrix(shadows, midtones, highlights) {
87
- // Map each band's [-100,100] range to Flash offsets [-255,255] and weight by band contribution.
86
+ // Map each band's [-100,100] range to normalized biases [-1,1] and weight by band contribution.
88
87
  // Shadows weight 0.25, midtones 0.5, highlights 0.25 — ensures the total offset range matches
89
88
  // a single-band full swing without clipping the combined result beyond ±255.
90
- const scale = 255 / 100;
89
+ const scale = 1 / 100;
91
90
  const rOff = (shadows[0] * 0.25 + midtones[0] * 0.5 + highlights[0] * 0.25) * scale;
92
91
  const gOff = (shadows[1] * 0.25 + midtones[1] * 0.5 + highlights[1] * 0.25) * scale;
93
92
  const bOff = (shadows[2] * 0.25 + midtones[2] * 0.5 + highlights[2] * 0.25) * scale;
@@ -104,9 +103,9 @@ export function createColorBalanceColorMatrix(shadows, midtones, highlights) {
104
103
  * 1 = solid tint color). Allocates a new array.
105
104
  */
106
105
  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;
106
+ const tr = (((packedRgba >>> 24) & 0xff) / 255) * amount;
107
+ const tg = (((packedRgba >>> 16) & 0xff) / 255) * amount;
108
+ const tb = (((packedRgba >>> 8) & 0xff) / 255) * amount;
110
109
  const keep = 1 - amount;
111
110
  // prettier-ignore
112
111
  return [
@@ -121,8 +120,8 @@ export function createColorMatrixFromTint(packedRgba, amount) {
121
120
  * increased contrast). Allocates a new array.
122
121
  */
123
122
  export function createContrastColorMatrix(amount) {
124
- // Translate to midpoint, scale, translate back: offset = 128 * (1 - amount).
125
- const offset = 128 * (1 - amount);
123
+ // Translate to midpoint, scale, translate back: bias = 0.5 * (1 - amount).
124
+ const offset = 0.5 * (1 - amount);
126
125
  // prettier-ignore
127
126
  return [
128
127
  amount, 0, 0, 0, offset,
@@ -188,21 +187,21 @@ export function createIdentityColorMatrix() {
188
187
  ];
189
188
  }
190
189
  /**
191
- * Returns an invert color matrix that produces `255 - channel` per RGB channel. Alpha is
190
+ * Returns an invert color matrix that produces `1 - channel` per RGB channel. Alpha is
192
191
  * unchanged. Allocates a new array.
193
192
  */
194
193
  export function createInvertColorMatrix() {
195
194
  // prettier-ignore
196
195
  return [
197
- -1, 0, 0, 0, 255,
198
- 0, -1, 0, 0, 255,
199
- 0, 0, -1, 0, 255,
196
+ -1, 0, 0, 0, 1,
197
+ 0, -1, 0, 0, 1,
198
+ 0, 0, -1, 0, 1,
200
199
  0, 0, 0, 1, 0,
201
200
  ];
202
201
  }
203
202
  /**
204
203
  * 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`
204
+ * range `[outBlack, outWhite]` with optional `gamma` correction. All values are normalized 0–1. `gamma`
206
205
  * defaults to 1 (linear). Allocates a new array.
207
206
  *
208
207
  * The remapping function is:
@@ -248,9 +247,9 @@ export function createPolaroidColorMatrix() {
248
247
  // Warm highlight, slightly desaturated mid-tones, lifted blacks.
249
248
  // prettier-ignore
250
249
  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,
250
+ 1.438, -0.062, -0.062, 0, -31.8 / 255,
251
+ -0.122, 1.378, -0.122, 0, 16.2 / 255,
252
+ -0.016, -0.016, 1.484, 0, -47.6 / 255,
254
253
  0, 0, 0, 1, 0,
255
254
  ];
256
255
  }
@@ -291,9 +290,9 @@ export function createTechnicolorColorMatrix() {
291
290
  // Derived from the classic Technicolor look formula widely cited in colour grading literature.
292
291
  // prettier-ignore
293
292
  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,
293
+ 1.9126, -0.8, -0.09, 0, 11.79 / 255,
294
+ -0.2, 1.7, -0.27, 0, -14.69 / 255,
295
+ -0.14, -0.21, 1.62, 0, -3.38 / 255,
297
296
  0, 0, 0, 1, 0,
298
297
  ];
299
298
  }
@@ -304,8 +303,8 @@ export function createTechnicolorColorMatrix() {
304
303
  export function createVintageColorMatrix() {
305
304
  // prettier-ignore
306
305
  return [
307
- 0.9, 0.05, 0.05, 0, 10,
308
- 0.0, 0.85, 0.0, 0, 5,
306
+ 0.9, 0.05, 0.05, 0, 10 / 255,
307
+ 0.0, 0.85, 0.0, 0, 5 / 255,
309
308
  0.0, 0.0, 0.75, 0, 0,
310
309
  0, 0, 0, 1, 0,
311
310
  ];
@@ -392,7 +391,7 @@ export function multiplyColorMatrix(a, b, out) {
392
391
  result[19] = a15 * b4 + a16 * b9 + a17 * b14 + a18 * b19 + a19;
393
392
  return result;
394
393
  }
395
- function clampByte(v) {
396
- return Math.max(0, Math.min(255, Math.round(v)));
394
+ function clampNormalizedByte(v) {
395
+ return Math.max(0, Math.min(255, Math.round(v * 255)));
397
396
  }
398
397
  //# sourceMappingURL=colorMatrixMath.js.map