@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,31 @@
|
|
|
1
|
+
import { createLiftGammaGainAdjustment } from './liftGammaGainAdjustment';
|
|
2
|
+
|
|
3
|
+
describe('createLiftGammaGainAdjustment', () => {
|
|
4
|
+
it('defaults to approximately neutral', () => {
|
|
5
|
+
// The packed gamma neutral 0x808080 is 128/255 ≈ 0.502, not exactly 0.5, so the default gamma
|
|
6
|
+
// exponent is ≈0.996 rather than 1 — faithful to the ported shader, which was never exactly neutral.
|
|
7
|
+
const adjustment = createLiftGammaGainAdjustment();
|
|
8
|
+
expect(adjustment.kind).toBe('LiftGammaGainAdjustment');
|
|
9
|
+
const out: [number, number, number] = [0, 0, 0];
|
|
10
|
+
adjustment.transform(out, 0.3, 0.6, 0.9);
|
|
11
|
+
expect(out[0]).toBeCloseTo(0.3, 2);
|
|
12
|
+
expect(out[1]).toBeCloseTo(0.6, 2);
|
|
13
|
+
expect(out[2]).toBeCloseTo(0.9, 2);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('applies gain as a per-channel multiplier', () => {
|
|
17
|
+
// gain 0x808080ff → ≈0.5 multiplier on each channel (before the near-neutral default gamma).
|
|
18
|
+
const adjustment = createLiftGammaGainAdjustment({ gain: 0x808080ff });
|
|
19
|
+
const out: [number, number, number] = [0, 0, 0];
|
|
20
|
+
adjustment.transform(out, 1, 1, 1);
|
|
21
|
+
expect(out[0]).toBeCloseTo(128 / 255, 2);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('lifts shadows toward the lift color', () => {
|
|
25
|
+
// lift 0xffffffff pulls dark values up toward white via (1 - rgb).
|
|
26
|
+
const adjustment = createLiftGammaGainAdjustment({ lift: 0xffffffff });
|
|
27
|
+
const out: [number, number, number] = [0, 0, 0];
|
|
28
|
+
adjustment.transform(out, 0, 0, 0);
|
|
29
|
+
expect(out[0]).toBeCloseTo(1, 4);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { bakeColorLut } from './colorLut';
|
|
2
|
+
import { createLookupTableGradeAdjustment } from './lookupTableGradeAdjustment';
|
|
3
|
+
|
|
4
|
+
describe('createLookupTableGradeAdjustment', () => {
|
|
5
|
+
it('is a neutral passthrough with no supplied LUT', () => {
|
|
6
|
+
const adjustment = createLookupTableGradeAdjustment();
|
|
7
|
+
expect(adjustment.kind).toBe('LookupTableGradeAdjustment');
|
|
8
|
+
const out: [number, number, number] = [0, 0, 0];
|
|
9
|
+
adjustment.transform(out, 0.2, 0.4, 0.6);
|
|
10
|
+
expect(out[0]).toBeCloseTo(0.2, 5);
|
|
11
|
+
expect(out[1]).toBeCloseTo(0.4, 5);
|
|
12
|
+
expect(out[2]).toBeCloseTo(0.6, 5);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('applies a supplied LUT at full strength', () => {
|
|
16
|
+
const invertLut = bakeColorLut(
|
|
17
|
+
[
|
|
18
|
+
(out, r, g, b) => {
|
|
19
|
+
out[0] = 1 - r;
|
|
20
|
+
out[1] = 1 - g;
|
|
21
|
+
out[2] = 1 - b;
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
16,
|
|
25
|
+
);
|
|
26
|
+
const adjustment = createLookupTableGradeAdjustment({ lut: invertLut });
|
|
27
|
+
const out: [number, number, number] = [0, 0, 0];
|
|
28
|
+
adjustment.transform(out, 0, 0, 0);
|
|
29
|
+
expect(out[0]).toBeCloseTo(1, 4);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('mixes toward the graded color by strength', () => {
|
|
33
|
+
const invertLut = bakeColorLut(
|
|
34
|
+
[
|
|
35
|
+
(out, r, g, b) => {
|
|
36
|
+
out[0] = 1 - r;
|
|
37
|
+
out[1] = 1 - g;
|
|
38
|
+
out[2] = 1 - b;
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
16,
|
|
42
|
+
);
|
|
43
|
+
const adjustment = createLookupTableGradeAdjustment({ lut: invertLut, strength: 0.5 });
|
|
44
|
+
const out: [number, number, number] = [0, 0, 0];
|
|
45
|
+
// input 0 → graded 1 → mix(0, 1, 0.5) = 0.5.
|
|
46
|
+
adjustment.transform(out, 0, 0, 0);
|
|
47
|
+
expect(out[0]).toBeCloseTo(0.5, 4);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { applyColorMatrixToColor } from './colorMatrixMath';
|
|
2
|
+
import { createSepiaAdjustment } from './sepiaAdjustment';
|
|
3
|
+
|
|
4
|
+
describe('createSepiaAdjustment', () => {
|
|
5
|
+
it('defaults to a full sepia tone', () => {
|
|
6
|
+
const adjustment = createSepiaAdjustment();
|
|
7
|
+
expect(adjustment.kind).toBe('SepiaAdjustment');
|
|
8
|
+
// White stays warm-white; red maps to the sepia red row (0.393·255 ≈ 100). Alpha preserved.
|
|
9
|
+
const red = applyColorMatrixToColor(adjustment.colorMatrix as number[], 0xff0000ff);
|
|
10
|
+
expect((red >>> 24) & 0xff).toBe(Math.round(0.393 * 255));
|
|
11
|
+
expect(red & 0xff).toBe(0xff);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('intensity 0 leaves color unchanged', () => {
|
|
15
|
+
const adjustment = createSepiaAdjustment({ intensity: 0 });
|
|
16
|
+
expect(applyColorMatrixToColor(adjustment.colorMatrix as number[], 0x3366ccff)).toBe(0x3366ccff);
|
|
17
|
+
});
|
|
18
|
+
});
|