@flighthq/effects 0.1.0 → 0.2.1-next.410.a23f189
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/bevelEffect.d.ts +3 -0
- package/dist/bevelEffect.d.ts.map +1 -0
- package/dist/bevelEffect.js +5 -0
- package/dist/bevelEffect.js.map +1 -0
- package/dist/blendEffect.d.ts +3 -0
- package/dist/blendEffect.d.ts.map +1 -0
- package/dist/blendEffect.js +10 -0
- package/dist/blendEffect.js.map +1 -0
- package/dist/blendModeMath.d.ts +6 -0
- package/dist/blendModeMath.d.ts.map +1 -0
- package/dist/blendModeMath.js +172 -0
- package/dist/blendModeMath.js.map +1 -0
- package/dist/blurDownsample.d.ts +17 -0
- package/dist/blurDownsample.d.ts.map +1 -0
- package/dist/blurDownsample.js +35 -0
- package/dist/blurDownsample.js.map +1 -0
- package/dist/blurEffect.d.ts +3 -0
- package/dist/blurEffect.d.ts.map +1 -0
- package/dist/blurEffect.js +7 -0
- package/dist/blurEffect.js.map +1 -0
- package/dist/boxBlurMath.d.ts +27 -0
- package/dist/boxBlurMath.d.ts.map +1 -0
- package/dist/boxBlurMath.js +64 -0
- package/dist/boxBlurMath.js.map +1 -0
- package/dist/compositeEffect.d.ts +3 -0
- package/dist/compositeEffect.d.ts.map +1 -0
- package/dist/compositeEffect.js +10 -0
- package/dist/compositeEffect.js.map +1 -0
- package/dist/compositeOperatorMath.d.ts +3 -0
- package/dist/compositeOperatorMath.d.ts.map +1 -0
- package/dist/compositeOperatorMath.js +65 -0
- package/dist/compositeOperatorMath.js.map +1 -0
- package/dist/convolutionEffect.d.ts +3 -0
- package/dist/convolutionEffect.d.ts.map +1 -0
- package/dist/convolutionEffect.js +4 -0
- package/dist/convolutionEffect.js.map +1 -0
- package/dist/dropShadowEffect.d.ts +3 -0
- package/dist/dropShadowEffect.d.ts.map +1 -0
- package/dist/dropShadowEffect.js +5 -0
- package/dist/dropShadowEffect.js.map +1 -0
- package/dist/gaussianKernel.d.ts +17 -0
- package/dist/gaussianKernel.d.ts.map +1 -0
- package/dist/gaussianKernel.js +49 -0
- package/dist/gaussianKernel.js.map +1 -0
- package/dist/gradientBevelEffect.d.ts +3 -0
- package/dist/gradientBevelEffect.d.ts.map +1 -0
- package/dist/gradientBevelEffect.js +5 -0
- package/dist/gradientBevelEffect.js.map +1 -0
- package/dist/gradientGlowEffect.d.ts +3 -0
- package/dist/gradientGlowEffect.d.ts.map +1 -0
- package/dist/gradientGlowEffect.js +5 -0
- package/dist/gradientGlowEffect.js.map +1 -0
- package/dist/index.d.ts +18 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -13
- package/dist/index.js.map +1 -1
- package/dist/innerGlowEffect.d.ts +3 -0
- package/dist/innerGlowEffect.d.ts.map +1 -0
- package/dist/innerGlowEffect.js +5 -0
- package/dist/innerGlowEffect.js.map +1 -0
- package/dist/innerShadowEffect.d.ts +3 -0
- package/dist/innerShadowEffect.d.ts.map +1 -0
- package/dist/innerShadowEffect.js +5 -0
- package/dist/innerShadowEffect.js.map +1 -0
- package/dist/linearSampledGaussian.d.ts +22 -0
- package/dist/linearSampledGaussian.d.ts.map +1 -0
- package/dist/linearSampledGaussian.js +56 -0
- package/dist/linearSampledGaussian.js.map +1 -0
- package/dist/medianEffect.d.ts +3 -0
- package/dist/medianEffect.d.ts.map +1 -0
- package/dist/medianEffect.js +4 -0
- package/dist/medianEffect.js.map +1 -0
- package/dist/outerGlowEffect.d.ts +3 -0
- package/dist/outerGlowEffect.d.ts.map +1 -0
- package/dist/outerGlowEffect.js +5 -0
- package/dist/outerGlowEffect.js.map +1 -0
- package/dist/renderEffectDefaults.js +51 -20
- package/dist/renderEffectDefaults.js.map +1 -1
- package/dist/renderEffectInputs.js +11 -11
- package/dist/renderEffectInputs.js.map +1 -1
- package/package.json +7 -2
- package/src/bevelEffect.test.ts +14 -0
- package/src/blendEffect.test.ts +23 -0
- package/src/blendModeMath.test.ts +160 -0
- package/src/blurDownsample.test.ts +46 -0
- package/src/blurEffect.test.ts +17 -0
- package/src/boxBlurMath.test.ts +96 -0
- package/src/compositeEffect.test.ts +21 -0
- package/src/compositeOperatorMath.test.ts +45 -0
- package/src/convolutionEffect.test.ts +20 -0
- package/src/dropShadowEffect.test.ts +14 -0
- package/src/gaussianKernel.test.ts +80 -0
- package/src/gradientBevelEffect.test.ts +21 -0
- package/src/gradientGlowEffect.test.ts +21 -0
- package/src/innerGlowEffect.test.ts +15 -0
- package/src/innerShadowEffect.test.ts +15 -0
- package/src/linearSampledGaussian.test.ts +87 -0
- package/src/medianEffect.test.ts +11 -0
- package/src/outerGlowEffect.test.ts +14 -0
- package/src/renderEffectDefaults.test.ts +13 -5
- package/src/renderEffectInputs.test.ts +3 -5
- package/src/renderEffectInterpolation.test.ts +6 -9
- package/src/renderEffectValidation.test.ts +2 -2
- package/dist/brightnessContrastEffect.d.ts +0 -3
- package/dist/brightnessContrastEffect.d.ts.map +0 -1
- package/dist/brightnessContrastEffect.js +0 -4
- package/dist/brightnessContrastEffect.js.map +0 -1
- package/dist/channelMixerEffect.d.ts +0 -3
- package/dist/channelMixerEffect.d.ts.map +0 -1
- package/dist/channelMixerEffect.js +0 -4
- package/dist/channelMixerEffect.js.map +0 -1
- package/dist/colorBlindSimulationEffect.d.ts +0 -3
- package/dist/colorBlindSimulationEffect.d.ts.map +0 -1
- package/dist/colorBlindSimulationEffect.js +0 -4
- package/dist/colorBlindSimulationEffect.js.map +0 -1
- package/dist/colorGradeEffect.d.ts +0 -3
- package/dist/colorGradeEffect.d.ts.map +0 -1
- package/dist/colorGradeEffect.js +0 -4
- package/dist/colorGradeEffect.js.map +0 -1
- package/dist/colorScienceMath.d.ts +0 -9
- package/dist/colorScienceMath.d.ts.map +0 -1
- package/dist/colorScienceMath.js +0 -135
- package/dist/colorScienceMath.js.map +0 -1
- package/dist/exposureEffect.d.ts +0 -3
- package/dist/exposureEffect.d.ts.map +0 -1
- package/dist/exposureEffect.js +0 -4
- package/dist/exposureEffect.js.map +0 -1
- package/dist/grayscaleEffect.d.ts +0 -3
- package/dist/grayscaleEffect.d.ts.map +0 -1
- package/dist/grayscaleEffect.js +0 -4
- package/dist/grayscaleEffect.js.map +0 -1
- package/dist/hueSaturationEffect.d.ts +0 -3
- package/dist/hueSaturationEffect.d.ts.map +0 -1
- package/dist/hueSaturationEffect.js +0 -4
- package/dist/hueSaturationEffect.js.map +0 -1
- package/dist/invertEffect.d.ts +0 -3
- package/dist/invertEffect.d.ts.map +0 -1
- package/dist/invertEffect.js +0 -4
- package/dist/invertEffect.js.map +0 -1
- package/dist/liftGammaGainEffect.d.ts +0 -3
- package/dist/liftGammaGainEffect.d.ts.map +0 -1
- package/dist/liftGammaGainEffect.js +0 -4
- package/dist/liftGammaGainEffect.js.map +0 -1
- package/dist/lookupTableGradeEffect.d.ts +0 -3
- package/dist/lookupTableGradeEffect.d.ts.map +0 -1
- package/dist/lookupTableGradeEffect.js +0 -4
- package/dist/lookupTableGradeEffect.js.map +0 -1
- package/dist/lutMath.d.ts +0 -7
- package/dist/lutMath.d.ts.map +0 -1
- package/dist/lutMath.js +0 -39
- package/dist/lutMath.js.map +0 -1
- package/dist/sepiaEffect.d.ts +0 -3
- package/dist/sepiaEffect.d.ts.map +0 -1
- package/dist/sepiaEffect.js +0 -4
- package/dist/sepiaEffect.js.map +0 -1
- package/src/brightnessContrastEffect.test.ts +0 -14
- package/src/channelMixerEffect.test.ts +0 -12
- package/src/colorBlindSimulationEffect.test.ts +0 -13
- package/src/colorGradeEffect.test.ts +0 -11
- package/src/colorScienceMath.test.ts +0 -160
- package/src/exposureEffect.test.ts +0 -7
- package/src/grayscaleEffect.test.ts +0 -11
- package/src/hueSaturationEffect.test.ts +0 -15
- package/src/invertEffect.test.ts +0 -11
- package/src/liftGammaGainEffect.test.ts +0 -15
- package/src/lookupTableGradeEffect.test.ts +0 -11
- package/src/lutMath.test.ts +0 -67
- package/src/sepiaEffect.test.ts +0 -11
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bevelEffect.d.ts","sourceRoot":"","sources":["../src/bevelEffect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAGnD,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,CAAM,GAAG,WAAW,CAEhG"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Bevel composite effect: the directional gradient of the blurred silhouette drives a highlight/shadow edge band, clipped by bevelType, then applies sourceMode compositing.
|
|
2
|
+
export function createBevelEffect(options = {}) {
|
|
3
|
+
return { kind: 'BevelEffect', ...options };
|
|
4
|
+
}
|
|
5
|
+
//# sourceMappingURL=bevelEffect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bevelEffect.js","sourceRoot":"","sources":["../src/bevelEffect.ts"],"names":[],"mappings":"AAEA,6KAA6K;AAC7K,MAAM,UAAU,iBAAiB,CAAC,UAA+C,EAAE;IACjF,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,OAAO,EAAE,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blendEffect.d.ts","sourceRoot":"","sources":["../src/blendEffect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAQtE,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,iBAAiB,EACvB,OAAO,GAAE,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC,CAAM,GACzD,WAAW,CAEb"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Advanced-blend composite effect: blends the incoming pipeline layer over a registered backdrop using
|
|
2
|
+
// a destination-reading / non-separable mode (the AdvancedBlendMode vocabulary the fixed-function
|
|
3
|
+
// BlendMode enum deliberately excludes). `mode` is required; `backdropKey` names the per-state backdrop
|
|
4
|
+
// texture the backend samples (registerGlBlendEffectBackdrop), and `opacity` scales the layer's
|
|
5
|
+
// contribution 0..1 (default 1). The backend bounces this through an offscreen and samples layer +
|
|
6
|
+
// backdrop — it is an effect you apply explicitly, not a cheap node property.
|
|
7
|
+
export function createBlendEffect(mode, options = {}) {
|
|
8
|
+
return { kind: 'BlendEffect', mode, ...options };
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=blendEffect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blendEffect.js","sourceRoot":"","sources":["../src/blendEffect.ts"],"names":[],"mappings":"AAEA,uGAAuG;AACvG,kGAAkG;AAClG,wGAAwG;AACxG,gGAAgG;AAChG,mGAAmG;AACnG,8EAA8E;AAC9E,MAAM,UAAU,iBAAiB,CAC/B,IAAuB,EACvB,UAAwD,EAAE;IAE1D,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AdvancedBlendMode } from '@flighthq/types';
|
|
2
|
+
export declare function blendNonSeparableRgb(mode: AdvancedBlendMode, cbR: number, cbG: number, cbB: number, csR: number, csG: number, csB: number, out: [number, number, number] | Float32Array | number[]): void;
|
|
3
|
+
export declare function getAdvancedBlendRgb(mode: AdvancedBlendMode, cbR: number, cbG: number, cbB: number, csR: number, csG: number, csB: number, out: [number, number, number] | Float32Array | number[]): void;
|
|
4
|
+
export declare function getSeparableBlendChannel(mode: AdvancedBlendMode, cb: number, cs: number): number;
|
|
5
|
+
export declare function isNonSeparableBlendMode(mode: AdvancedBlendMode): boolean;
|
|
6
|
+
//# sourceMappingURL=blendModeMath.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blendModeMath.d.ts","sourceRoot":"","sources":["../src/blendModeMath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAiBpD,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,iBAAiB,EACvB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,YAAY,GAAG,MAAM,EAAE,GACtD,IAAI,CAgCN;AAKD,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,iBAAiB,EACvB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,YAAY,GAAG,MAAM,EAAE,GACtD,IAAI,CAWN;AAID,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,iBAAiB,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CA4BhG;AAID,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAOxE"}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { AdvancedBlendMode } from '@flighthq/types';
|
|
2
|
+
// Pure blend-mode math — the substrate-agnostic ground truth the GL (and any future) backend shaders
|
|
3
|
+
// mirror, so the composite-recipe fragment source can be verified against plain numbers. All values are
|
|
4
|
+
// normalized 0..1 (backdrop `cb`, source `cs`). The formulas follow the W3C Compositing and Blending
|
|
5
|
+
// spec: the seven separable modes blend each channel independently (getSeparableBlendChannel); the four
|
|
6
|
+
// non-separable HSL modes blend a whole RGB triple by transplanting one HSL attribute
|
|
7
|
+
// (blendNonSeparableRgb). getAdvancedBlendRgb dispatches either path by mode, writing into `out`.
|
|
8
|
+
//
|
|
9
|
+
// This is the blend function B(cb, cs) alone — the caller composites B into the final pixel with the
|
|
10
|
+
// backdrop/source alphas (Porter-Duff source-over of the blended color), which is a separate step the
|
|
11
|
+
// backend's alpha compositing performs. Unknown modes fall through to Normal (the source color).
|
|
12
|
+
// The four non-separable HSL blend modes on 0..1 RGB, following the W3C spec's Hue/Sat/Color/Lum
|
|
13
|
+
// primitives (Lum via a luminosity-preserving clip, Sat via setSat on sorted channels). Writes the
|
|
14
|
+
// blended triple into `out[0..2]`. Alias-safe: reads all inputs before writing `out`. Unknown modes
|
|
15
|
+
// fall through to the source triple (Normal).
|
|
16
|
+
export function blendNonSeparableRgb(mode, cbR, cbG, cbB, csR, csG, csB, out) {
|
|
17
|
+
let r;
|
|
18
|
+
let g;
|
|
19
|
+
let b;
|
|
20
|
+
switch (mode) {
|
|
21
|
+
case AdvancedBlendMode.Hue:
|
|
22
|
+
// Source hue, backdrop saturation, backdrop luminosity.
|
|
23
|
+
[r, g, b] = setBlendSaturation(csR, csG, csB, blendSaturation(cbR, cbG, cbB));
|
|
24
|
+
[r, g, b] = setBlendLuminosity(r, g, b, blendLuminosity(cbR, cbG, cbB));
|
|
25
|
+
break;
|
|
26
|
+
case AdvancedBlendMode.Saturation:
|
|
27
|
+
// Backdrop hue, source saturation, backdrop luminosity.
|
|
28
|
+
[r, g, b] = setBlendSaturation(cbR, cbG, cbB, blendSaturation(csR, csG, csB));
|
|
29
|
+
[r, g, b] = setBlendLuminosity(r, g, b, blendLuminosity(cbR, cbG, cbB));
|
|
30
|
+
break;
|
|
31
|
+
case AdvancedBlendMode.Color:
|
|
32
|
+
// Source hue + saturation, backdrop luminosity.
|
|
33
|
+
[r, g, b] = setBlendLuminosity(csR, csG, csB, blendLuminosity(cbR, cbG, cbB));
|
|
34
|
+
break;
|
|
35
|
+
case AdvancedBlendMode.Luminosity:
|
|
36
|
+
// Backdrop hue + saturation, source luminosity.
|
|
37
|
+
[r, g, b] = setBlendLuminosity(cbR, cbG, cbB, blendLuminosity(csR, csG, csB));
|
|
38
|
+
break;
|
|
39
|
+
default:
|
|
40
|
+
r = csR;
|
|
41
|
+
g = csG;
|
|
42
|
+
b = csB;
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
out[0] = r;
|
|
46
|
+
out[1] = g;
|
|
47
|
+
out[2] = b;
|
|
48
|
+
}
|
|
49
|
+
// Dispatches the advanced blend for a whole RGB triple, writing the blended (pre-alpha-composite) color
|
|
50
|
+
// into `out[0..2]`. Separable modes reduce to three getSeparableBlendChannel calls; the HSL modes route
|
|
51
|
+
// to blendNonSeparableRgb. Alias-safe: reads all six inputs before writing `out`.
|
|
52
|
+
export function getAdvancedBlendRgb(mode, cbR, cbG, cbB, csR, csG, csB, out) {
|
|
53
|
+
if (isNonSeparableBlendMode(mode)) {
|
|
54
|
+
blendNonSeparableRgb(mode, cbR, cbG, cbB, csR, csG, csB, out);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const r = getSeparableBlendChannel(mode, cbR, csR);
|
|
58
|
+
const g = getSeparableBlendChannel(mode, cbG, csG);
|
|
59
|
+
const b = getSeparableBlendChannel(mode, cbB, csB);
|
|
60
|
+
out[0] = r;
|
|
61
|
+
out[1] = g;
|
|
62
|
+
out[2] = b;
|
|
63
|
+
}
|
|
64
|
+
// Separable per-channel blend on 0..1 values (backdrop `cb`, source `cs`). Covers the seven separable
|
|
65
|
+
// AdvancedBlendMode members; any non-separable or unknown mode returns the source channel (Normal).
|
|
66
|
+
export function getSeparableBlendChannel(mode, cb, cs) {
|
|
67
|
+
switch (mode) {
|
|
68
|
+
case AdvancedBlendMode.Overlay:
|
|
69
|
+
// Overlay = HardLight with operands swapped: hard-light the backdrop by the source.
|
|
70
|
+
return cb <= 0.5 ? 2 * cb * cs : 1 - 2 * (1 - cb) * (1 - cs);
|
|
71
|
+
case AdvancedBlendMode.HardLight:
|
|
72
|
+
return cs <= 0.5 ? 2 * cb * cs : 1 - 2 * (1 - cb) * (1 - cs);
|
|
73
|
+
case AdvancedBlendMode.SoftLight: {
|
|
74
|
+
const d = cb <= 0.25 ? ((16 * cb - 12) * cb + 4) * cb : Math.sqrt(cb);
|
|
75
|
+
return cs <= 0.5 ? cb - (1 - 2 * cs) * cb * (1 - cb) : cb + (2 * cs - 1) * (d - cb);
|
|
76
|
+
}
|
|
77
|
+
case AdvancedBlendMode.Difference:
|
|
78
|
+
return Math.abs(cb - cs);
|
|
79
|
+
case AdvancedBlendMode.Exclusion:
|
|
80
|
+
return cb + cs - 2 * cb * cs;
|
|
81
|
+
case AdvancedBlendMode.ColorDodge:
|
|
82
|
+
// W3C: 0→0, source==1→1, else min(1, backdrop / (1 - source)).
|
|
83
|
+
if (cb <= 0)
|
|
84
|
+
return 0;
|
|
85
|
+
if (cs >= 1)
|
|
86
|
+
return 1;
|
|
87
|
+
return Math.min(1, cb / (1 - cs));
|
|
88
|
+
case AdvancedBlendMode.ColorBurn:
|
|
89
|
+
// W3C: 1→1, source==0→0, else 1 - min(1, (1 - backdrop) / source).
|
|
90
|
+
if (cb >= 1)
|
|
91
|
+
return 1;
|
|
92
|
+
if (cs <= 0)
|
|
93
|
+
return 0;
|
|
94
|
+
return 1 - Math.min(1, (1 - cb) / cs);
|
|
95
|
+
default:
|
|
96
|
+
return cs;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// True for the four non-separable HSL blend modes (Hue/Saturation/Color/Luminosity), which cannot be
|
|
100
|
+
// computed per channel because they transplant a whole HSL attribute from one triple to the other.
|
|
101
|
+
export function isNonSeparableBlendMode(mode) {
|
|
102
|
+
return (mode === AdvancedBlendMode.Hue ||
|
|
103
|
+
mode === AdvancedBlendMode.Saturation ||
|
|
104
|
+
mode === AdvancedBlendMode.Color ||
|
|
105
|
+
mode === AdvancedBlendMode.Luminosity);
|
|
106
|
+
}
|
|
107
|
+
// W3C lum(): the Rec.601 luma of an RGB triple.
|
|
108
|
+
function blendLuminosity(r, g, b) {
|
|
109
|
+
return 0.3 * r + 0.59 * g + 0.11 * b;
|
|
110
|
+
}
|
|
111
|
+
// W3C sat(): the chroma range (max - min) of an RGB triple.
|
|
112
|
+
function blendSaturation(r, g, b) {
|
|
113
|
+
return Math.max(r, g, b) - Math.min(r, g, b);
|
|
114
|
+
}
|
|
115
|
+
// W3C ClipColor(): pull any out-of-gamut channel back toward the color's luminosity so the result stays
|
|
116
|
+
// in 0..1 without shifting perceived brightness.
|
|
117
|
+
function clipBlendColor(r, g, b) {
|
|
118
|
+
const l = blendLuminosity(r, g, b);
|
|
119
|
+
const min = Math.min(r, g, b);
|
|
120
|
+
const max = Math.max(r, g, b);
|
|
121
|
+
let cr = r;
|
|
122
|
+
let cg = g;
|
|
123
|
+
let cb = b;
|
|
124
|
+
if (min < 0) {
|
|
125
|
+
const denom = l - min;
|
|
126
|
+
cr = l + ((cr - l) * l) / denom;
|
|
127
|
+
cg = l + ((cg - l) * l) / denom;
|
|
128
|
+
cb = l + ((cb - l) * l) / denom;
|
|
129
|
+
}
|
|
130
|
+
if (max > 1) {
|
|
131
|
+
const denom = max - l;
|
|
132
|
+
cr = l + ((cr - l) * (1 - l)) / denom;
|
|
133
|
+
cg = l + ((cg - l) * (1 - l)) / denom;
|
|
134
|
+
cb = l + ((cb - l) * (1 - l)) / denom;
|
|
135
|
+
}
|
|
136
|
+
return [cr, cg, cb];
|
|
137
|
+
}
|
|
138
|
+
// W3C SetLum(): shift an RGB triple to the target luminosity, then clip back into gamut.
|
|
139
|
+
function setBlendLuminosity(r, g, b, target) {
|
|
140
|
+
const d = target - blendLuminosity(r, g, b);
|
|
141
|
+
return clipBlendColor(r + d, g + d, b + d);
|
|
142
|
+
}
|
|
143
|
+
// W3C SetSat(): rescale an RGB triple's mid/max channels to the target saturation while pinning its
|
|
144
|
+
// minimum to black, preserving hue. Operates by resolving the sorted (min, mid, max) positions.
|
|
145
|
+
function setBlendSaturation(r, g, b, target) {
|
|
146
|
+
const out = [r, g, b];
|
|
147
|
+
// Indices of the min / mid / max channels.
|
|
148
|
+
let iMin = 0;
|
|
149
|
+
let iMax = 0;
|
|
150
|
+
for (let i = 1; i < 3; i++) {
|
|
151
|
+
if (out[i] < out[iMin])
|
|
152
|
+
iMin = i;
|
|
153
|
+
if (out[i] > out[iMax])
|
|
154
|
+
iMax = i;
|
|
155
|
+
}
|
|
156
|
+
if (iMin === iMax) {
|
|
157
|
+
// All channels equal after a degenerate sort — pick a distinct mid deterministically.
|
|
158
|
+
iMax = (iMin + 1) % 3;
|
|
159
|
+
}
|
|
160
|
+
const iMid = 3 - iMin - iMax;
|
|
161
|
+
if (out[iMax] > out[iMin]) {
|
|
162
|
+
out[iMid] = ((out[iMid] - out[iMin]) * target) / (out[iMax] - out[iMin]);
|
|
163
|
+
out[iMax] = target;
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
out[iMid] = 0;
|
|
167
|
+
out[iMax] = 0;
|
|
168
|
+
}
|
|
169
|
+
out[iMin] = 0;
|
|
170
|
+
return out;
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=blendModeMath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blendModeMath.js","sourceRoot":"","sources":["../src/blendModeMath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,qGAAqG;AACrG,wGAAwG;AACxG,qGAAqG;AACrG,wGAAwG;AACxG,sFAAsF;AACtF,kGAAkG;AAClG,EAAE;AACF,qGAAqG;AACrG,sGAAsG;AACtG,iGAAiG;AAEjG,iGAAiG;AACjG,mGAAmG;AACnG,oGAAoG;AACpG,8CAA8C;AAC9C,MAAM,UAAU,oBAAoB,CAClC,IAAuB,EACvB,GAAW,EACX,GAAW,EACX,GAAW,EACX,GAAW,EACX,GAAW,EACX,GAAW,EACX,GAAuD;IAEvD,IAAI,CAAS,CAAC;IACd,IAAI,CAAS,CAAC;IACd,IAAI,CAAS,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AI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;QACzE,GAAG,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;IACrB,CAAC;SAAM,CAAC;QACN,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACd,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAChB,CAAC;IACD,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACd,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the power-of-two downsample level to apply before blurring with standard deviation
|
|
3
|
+
* `sigma`, following Skia's scale-then-blur strategy: large blurs are cheaper if the source is first
|
|
4
|
+
* halved in each dimension `level` times and blurred with a proportionally smaller residual sigma.
|
|
5
|
+
* The level is the smallest non-negative integer such that `sigma / 2^level` falls at or below
|
|
6
|
+
* `BLUR_DOWNSAMPLE_MAX_SIGMA`, i.e. `ceil(log2(sigma / max))` clamped to `>= 0`. Blurs at or below
|
|
7
|
+
* that threshold run at full resolution (level 0). `sigma <= 0` returns 0.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getBlurDownsampleLevel(sigma: number): number;
|
|
10
|
+
/**
|
|
11
|
+
* Returns the residual standard deviation to blur with after downsampling by `level` power-of-two
|
|
12
|
+
* steps: `sigma / 2^level`. Blurring a `2^level`-times-downsampled image with this residual sigma
|
|
13
|
+
* reproduces a full-resolution blur of `sigma`, because a blur at half resolution covers twice the
|
|
14
|
+
* distance in source space. `sigma <= 0` returns 0.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getBlurResidualSigma(sigma: number, level: number): number;
|
|
17
|
+
//# sourceMappingURL=blurDownsample.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blurDownsample.d.ts","sourceRoot":"","sources":["../src/blurDownsample.ts"],"names":[],"mappings":"AAOA;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAG5D;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAGzE"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Scale-then-blur downsample selection for large blurs. Substrate-agnostic recipe math.
|
|
2
|
+
//
|
|
3
|
+
// Copied verbatim from filters-math during the filters→effects migration — effects is the
|
|
4
|
+
// canonical home for the spatial-effect blur math (effect-adjustment-architecture.md, migration
|
|
5
|
+
// step 4). filters-math keeps its copy until the filters* packages retire; the duplicate is
|
|
6
|
+
// deliberate for the duration (mirrors the Phase 1 colorMatrixMath port).
|
|
7
|
+
/**
|
|
8
|
+
* Returns the power-of-two downsample level to apply before blurring with standard deviation
|
|
9
|
+
* `sigma`, following Skia's scale-then-blur strategy: large blurs are cheaper if the source is first
|
|
10
|
+
* halved in each dimension `level` times and blurred with a proportionally smaller residual sigma.
|
|
11
|
+
* The level is the smallest non-negative integer such that `sigma / 2^level` falls at or below
|
|
12
|
+
* `BLUR_DOWNSAMPLE_MAX_SIGMA`, i.e. `ceil(log2(sigma / max))` clamped to `>= 0`. Blurs at or below
|
|
13
|
+
* that threshold run at full resolution (level 0). `sigma <= 0` returns 0.
|
|
14
|
+
*/
|
|
15
|
+
export function getBlurDownsampleLevel(sigma) {
|
|
16
|
+
if (sigma <= BLUR_DOWNSAMPLE_MAX_SIGMA)
|
|
17
|
+
return 0;
|
|
18
|
+
return Math.ceil(Math.log2(sigma / BLUR_DOWNSAMPLE_MAX_SIGMA));
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Returns the residual standard deviation to blur with after downsampling by `level` power-of-two
|
|
22
|
+
* steps: `sigma / 2^level`. Blurring a `2^level`-times-downsampled image with this residual sigma
|
|
23
|
+
* reproduces a full-resolution blur of `sigma`, because a blur at half resolution covers twice the
|
|
24
|
+
* distance in source space. `sigma <= 0` returns 0.
|
|
25
|
+
*/
|
|
26
|
+
export function getBlurResidualSigma(sigma, level) {
|
|
27
|
+
if (sigma <= 0)
|
|
28
|
+
return 0;
|
|
29
|
+
return sigma / 2 ** level;
|
|
30
|
+
}
|
|
31
|
+
// The largest residual sigma a downsample level is allowed to leave. Matches Skia's GPU blur cap:
|
|
32
|
+
// beyond ~4 the box/Gaussian passes gain little accuracy per pixel touched, so halving resolution
|
|
33
|
+
// and blurring the smaller image is the better trade.
|
|
34
|
+
const BLUR_DOWNSAMPLE_MAX_SIGMA = 4;
|
|
35
|
+
//# sourceMappingURL=blurDownsample.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blurDownsample.js","sourceRoot":"","sources":["../src/blurDownsample.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,EAAE;AACF,0FAA0F;AAC1F,gGAAgG;AAChG,4FAA4F;AAC5F,0EAA0E;AAE1E;;;;;;;GAOG;AACH,MAAM,UAAU,sBAAsB,CAAC,KAAa;IAClD,IAAI,KAAK,IAAI,yBAAyB;QAAE,OAAO,CAAC,CAAC;IACjD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,yBAAyB,CAAC,CAAC,CAAC;AACjE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAa,EAAE,KAAa;IAC/D,IAAI,KAAK,IAAI,CAAC;QAAE,OAAO,CAAC,CAAC;IACzB,OAAO,KAAK,GAAG,CAAC,IAAI,KAAK,CAAC;AAC5B,CAAC;AAED,kGAAkG;AAClG,kGAAkG;AAClG,sDAAsD;AACtD,MAAM,yBAAyB,GAAG,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blurEffect.d.ts","sourceRoot":"","sources":["../src/blurEffect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAKlD,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,QAAQ,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAM,GAAG,UAAU,CAE7F"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Plain separable Gaussian blur intent. `blurX`/`blurY` are the per-axis Gaussian standard deviations
|
|
2
|
+
// in pixels; the backends realize them as a two-pass separable blur bouncing through an offscreen
|
|
3
|
+
// target. The spatial-effect sibling of the directional/radial/motion blur variants.
|
|
4
|
+
export function createBlurEffect(options = {}) {
|
|
5
|
+
return { kind: 'BlurEffect', ...options };
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=blurEffect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blurEffect.js","sourceRoot":"","sources":["../src/blurEffect.ts"],"names":[],"mappings":"AAEA,sGAAsG;AACtG,kGAAkG;AAClG,qFAAqF;AACrF,MAAM,UAAU,gBAAgB,CAAC,UAA8C,EAAE;IAC/E,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,OAAO,EAAE,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the box-blur radius for pass `pass` of `passes`, using two adjacent
|
|
3
|
+
* odd box widths so the combined variance tracks a Gaussian of standard
|
|
4
|
+
* deviation `sigma`. The lower passes use the smaller width and the remaining
|
|
5
|
+
* passes use the next odd width up; this avoids the overshoot that repeating a
|
|
6
|
+
* single rounded radius `passes` times accumulates. Radii are non-decreasing in
|
|
7
|
+
* `pass`. Use this for backends that can vary the radius per pass (such as the
|
|
8
|
+
* Gl separable passes); `computeBoxBlurRadius` covers backends that apply one
|
|
9
|
+
* uniform radius across every pass.
|
|
10
|
+
*/
|
|
11
|
+
export declare function computeBoxBlurPassRadius(sigma: number, passes: number, pass: number): number;
|
|
12
|
+
/**
|
|
13
|
+
* Converts sigma to the single box-blur radius whose repeated application
|
|
14
|
+
* (`passes` times) has the same variance as a Gaussian with standard deviation
|
|
15
|
+
* `sigma`. Use this for backends that apply one uniform radius across every
|
|
16
|
+
* pass; for backends that can vary the radius per pass, `computeBoxBlurPassRadius`
|
|
17
|
+
* tracks `sigma` more closely.
|
|
18
|
+
*/
|
|
19
|
+
export declare function computeBoxBlurRadius(sigma: number, passes: number): number;
|
|
20
|
+
/**
|
|
21
|
+
* Converts a box-blur radius to the approximate Gaussian sigma that a single-pass box blur of
|
|
22
|
+
* that radius corresponds to. Inverse of the `computeBoxBlurRadius` uniform-pass formula:
|
|
23
|
+
* sigma = sqrt(passes * (2*radius + 1)^2 / 12). Useful for the reverse mapping (e.g. to feed a
|
|
24
|
+
* sigma-based backend from a Flash `blurX` value).
|
|
25
|
+
*/
|
|
26
|
+
export declare function computeGaussianSigmaForBlurRadius(radius: number, passes: number): number;
|
|
27
|
+
//# sourceMappingURL=boxBlurMath.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boxBlurMath.d.ts","sourceRoot":"","sources":["../src/boxBlurMath.ts"],"names":[],"mappings":"AAQA;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAM5F;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAG1E;AAED;;;;;GAKG;AACH,wBAAgB,iCAAiC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAIxF"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Box-blur radius/sigma recipe math. Substrate-agnostic: every backend derives identical box-blur
|
|
2
|
+
// pass radii from the same sigma so the GL, WGPU, and CPU spreads match.
|
|
3
|
+
//
|
|
4
|
+
// Copied verbatim from filters-math during the filters→effects migration — effects is the
|
|
5
|
+
// canonical home for the spatial-effect blur math (effect-adjustment-architecture.md, migration
|
|
6
|
+
// step 4). filters-math keeps its copy until the filters* packages retire; the duplicate is
|
|
7
|
+
// deliberate for the duration (mirrors the Phase 1 colorMatrixMath port).
|
|
8
|
+
/**
|
|
9
|
+
* Returns the box-blur radius for pass `pass` of `passes`, using two adjacent
|
|
10
|
+
* odd box widths so the combined variance tracks a Gaussian of standard
|
|
11
|
+
* deviation `sigma`. The lower passes use the smaller width and the remaining
|
|
12
|
+
* passes use the next odd width up; this avoids the overshoot that repeating a
|
|
13
|
+
* single rounded radius `passes` times accumulates. Radii are non-decreasing in
|
|
14
|
+
* `pass`. Use this for backends that can vary the radius per pass (such as the
|
|
15
|
+
* Gl separable passes); `computeBoxBlurRadius` covers backends that apply one
|
|
16
|
+
* uniform radius across every pass.
|
|
17
|
+
*/
|
|
18
|
+
export function computeBoxBlurPassRadius(sigma, passes, pass) {
|
|
19
|
+
if (sigma <= 0)
|
|
20
|
+
return 0;
|
|
21
|
+
const lowerWidth = computeBoxBlurLowerWidth(sigma, passes);
|
|
22
|
+
const lowerCount = computeBoxBlurLowerPassCount(sigma, passes, lowerWidth);
|
|
23
|
+
const width = pass < lowerCount ? lowerWidth : lowerWidth + 2;
|
|
24
|
+
return Math.max(0, (width - 1) / 2);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Converts sigma to the single box-blur radius whose repeated application
|
|
28
|
+
* (`passes` times) has the same variance as a Gaussian with standard deviation
|
|
29
|
+
* `sigma`. Use this for backends that apply one uniform radius across every
|
|
30
|
+
* pass; for backends that can vary the radius per pass, `computeBoxBlurPassRadius`
|
|
31
|
+
* tracks `sigma` more closely.
|
|
32
|
+
*/
|
|
33
|
+
export function computeBoxBlurRadius(sigma, passes) {
|
|
34
|
+
if (sigma <= 0)
|
|
35
|
+
return 0;
|
|
36
|
+
return Math.max(0, Math.round((-1 + Math.sqrt(1 + (12 * sigma * sigma) / passes)) / 2));
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Converts a box-blur radius to the approximate Gaussian sigma that a single-pass box blur of
|
|
40
|
+
* that radius corresponds to. Inverse of the `computeBoxBlurRadius` uniform-pass formula:
|
|
41
|
+
* sigma = sqrt(passes * (2*radius + 1)^2 / 12). Useful for the reverse mapping (e.g. to feed a
|
|
42
|
+
* sigma-based backend from a Flash `blurX` value).
|
|
43
|
+
*/
|
|
44
|
+
export function computeGaussianSigmaForBlurRadius(radius, passes) {
|
|
45
|
+
if (radius <= 0 || passes <= 0)
|
|
46
|
+
return 0;
|
|
47
|
+
const width = 2 * radius + 1;
|
|
48
|
+
return Math.sqrt((passes * width * width) / 12);
|
|
49
|
+
}
|
|
50
|
+
// Largest odd box width whose `passes`-fold variance stays at or below a Gaussian
|
|
51
|
+
// of standard deviation `sigma`. Odd keeps the radius (width - 1) / 2 integral.
|
|
52
|
+
function computeBoxBlurLowerWidth(sigma, passes) {
|
|
53
|
+
let width = Math.floor(Math.sqrt((12 * sigma * sigma) / passes + 1));
|
|
54
|
+
if (width % 2 === 0)
|
|
55
|
+
width -= 1;
|
|
56
|
+
return width;
|
|
57
|
+
}
|
|
58
|
+
// Number of passes that use `lowerWidth`; the remaining passes use the next odd
|
|
59
|
+
// width up so the combined variance tracks sigma. Derived from
|
|
60
|
+
// m·(wl² - 1)/12 + (passes - m)·(wu² - 1)/12 = σ², with wu = wl + 2.
|
|
61
|
+
function computeBoxBlurLowerPassCount(sigma, passes, lowerWidth) {
|
|
62
|
+
return Math.round((12 * sigma * sigma - passes * (lowerWidth * lowerWidth + 4 * lowerWidth + 3)) / (-4 * lowerWidth - 4));
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=boxBlurMath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boxBlurMath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C7B,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,KAAK,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;AAClD,CAAC;AAED,kFAAkF;AAClF,gFAAgF;AAChF,SAAS,wBAAwB,CAAC,KAAa,EAAE,MAAc;IAC7D,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,KAAK,GAAG,KAAK,CAAC,GAAG,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;IACrE,IAAI,KAAK,GAAG,CAAC,KAAK,CAAC;QAAE,KAAK,IAAI,CAAC,CAAC;IAChC,OAAO,KAAK,CAAC;AACf,CAAC;AAED,gFAAgF;AAChF,+DAA+D;AAC/D,qEAAqE;AACrE,SAAS,4BAA4B,CAAC,KAAa,EAAE,MAAc,EAAE,UAAkB;IACrF,OAAO,IAAI,CAAC,KAAK,CACf,CAAC,EAAE,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,CAAC,UAAU,GAAG,UAAU,GAAG,CAAC,GAAG,UAAU,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,UAAU,GAAG,CAAC,CAAC,CACvG,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { CompositeEffect, CompositeOperator } from '@flighthq/types';
|
|
2
|
+
export declare function createCompositeEffect(operator: CompositeOperator, options?: Readonly<Omit<CompositeEffect, 'kind' | 'operator'>>): CompositeEffect;
|
|
3
|
+
//# sourceMappingURL=compositeEffect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compositeEffect.d.ts","sourceRoot":"","sources":["../src/compositeEffect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAQ1E,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,iBAAiB,EAC3B,OAAO,GAAE,QAAQ,CAAC,IAAI,CAAC,eAAe,EAAE,MAAM,GAAG,UAAU,CAAC,CAAM,GACjE,eAAe,CAEjB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Porter-Duff composite effect: merges the incoming pipeline layer over a registered backdrop with a
|
|
2
|
+
// coverage operator (the CompositeOperator vocabulary — Erase = DestinationOut, Alpha = DestinationIn,
|
|
3
|
+
// and the rest of the set). `operator` is required; `backdropKey` names the per-state backdrop texture the
|
|
4
|
+
// backend samples. It is the cheap sibling of createBlendEffect: a fixed-function coverage combine rather
|
|
5
|
+
// than a shader blend, but still an explicit effect because a non-source-over operator is only meaningful
|
|
6
|
+
// against an isolated layer.
|
|
7
|
+
export function createCompositeEffect(operator, options = {}) {
|
|
8
|
+
return { kind: 'CompositeEffect', operator, ...options };
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=compositeEffect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compositeEffect.js","sourceRoot":"","sources":["../src/compositeEffect.ts"],"names":[],"mappings":"AAEA,qGAAqG;AACrG,uGAAuG;AACvG,2GAA2G;AAC3G,0GAA0G;AAC1G,0GAA0G;AAC1G,6BAA6B;AAC7B,MAAM,UAAU,qBAAqB,CACnC,QAA2B,EAC3B,UAAgE,EAAE;IAElE,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,QAAQ,EAAE,GAAG,OAAO,EAAE,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { CompositeOperator } from '@flighthq/types';
|
|
2
|
+
export declare function getCompositeOperatorFactors(operator: CompositeOperator, sourceAlpha: number, backdropAlpha: number, out: [number, number] | Float32Array | number[]): void;
|
|
3
|
+
//# sourceMappingURL=compositeOperatorMath.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compositeOperatorMath.d.ts","sourceRoot":"","sources":["../src/compositeOperatorMath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAUpD,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,iBAAiB,EAC3B,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,MAAM,EACrB,GAAG,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,YAAY,GAAG,MAAM,EAAE,GAC9C,IAAI,CAsDN"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { CompositeOperator } from '@flighthq/types';
|
|
2
|
+
// Premultiplied Porter-Duff coverage factors — the substrate-agnostic ground truth for how an isolated
|
|
3
|
+
// layer (`source`) merges into its backdrop. The composited pixel is `Fa*source + Fb*backdrop` applied to
|
|
4
|
+
// premultiplied color (rgb and a alike), where Fa/Fb depend only on the operator and the two coverage
|
|
5
|
+
// alphas (`sourceAlpha` = as, `backdropAlpha` = ab). The GL fixed-function blendFunc factor pairs and the
|
|
6
|
+
// Canvas globalCompositeOperation names both mirror these, so every backend is verifiable against plain
|
|
7
|
+
// numbers. This is a closed set (the eleven Porter-Duff operators); custom operators are wired per-backend
|
|
8
|
+
// (registerGlCompositeOperator) with their own factors, so an unknown operator here falls through to
|
|
9
|
+
// SourceOver. Writes [Fa, Fb] into `out`; alias-safe (reads inputs before writing).
|
|
10
|
+
export function getCompositeOperatorFactors(operator, sourceAlpha, backdropAlpha, out) {
|
|
11
|
+
const as = sourceAlpha;
|
|
12
|
+
const ab = backdropAlpha;
|
|
13
|
+
let fa;
|
|
14
|
+
let fb;
|
|
15
|
+
switch (operator) {
|
|
16
|
+
case CompositeOperator.Clear:
|
|
17
|
+
fa = 0;
|
|
18
|
+
fb = 0;
|
|
19
|
+
break;
|
|
20
|
+
case CompositeOperator.Copy:
|
|
21
|
+
fa = 1;
|
|
22
|
+
fb = 0;
|
|
23
|
+
break;
|
|
24
|
+
case CompositeOperator.DestinationAtop:
|
|
25
|
+
fa = 1 - ab;
|
|
26
|
+
fb = as;
|
|
27
|
+
break;
|
|
28
|
+
case CompositeOperator.DestinationIn:
|
|
29
|
+
fa = 0;
|
|
30
|
+
fb = as;
|
|
31
|
+
break;
|
|
32
|
+
case CompositeOperator.DestinationOut:
|
|
33
|
+
fa = 0;
|
|
34
|
+
fb = 1 - as;
|
|
35
|
+
break;
|
|
36
|
+
case CompositeOperator.DestinationOver:
|
|
37
|
+
fa = 1 - ab;
|
|
38
|
+
fb = 1;
|
|
39
|
+
break;
|
|
40
|
+
case CompositeOperator.SourceAtop:
|
|
41
|
+
fa = ab;
|
|
42
|
+
fb = 1 - as;
|
|
43
|
+
break;
|
|
44
|
+
case CompositeOperator.SourceIn:
|
|
45
|
+
fa = ab;
|
|
46
|
+
fb = 0;
|
|
47
|
+
break;
|
|
48
|
+
case CompositeOperator.SourceOut:
|
|
49
|
+
fa = 1 - ab;
|
|
50
|
+
fb = 0;
|
|
51
|
+
break;
|
|
52
|
+
case CompositeOperator.Xor:
|
|
53
|
+
fa = 1 - ab;
|
|
54
|
+
fb = 1 - as;
|
|
55
|
+
break;
|
|
56
|
+
default:
|
|
57
|
+
// SourceOver: source over backdrop.
|
|
58
|
+
fa = 1;
|
|
59
|
+
fb = 1 - as;
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
out[0] = fa;
|
|
63
|
+
out[1] = fb;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=compositeOperatorMath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compositeOperatorMath.js","sourceRoot":"","sources":["../src/compositeOperatorMath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,uGAAuG;AACvG,0GAA0G;AAC1G,sGAAsG;AACtG,0GAA0G;AAC1G,wGAAwG;AACxG,2GAA2G;AAC3G,qGAAqG;AACrG,oFAAoF;AACpF,MAAM,UAAU,2BAA2B,CACzC,QAA2B,EAC3B,WAAmB,EACnB,aAAq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AE,GAAG,CAAC,GAAG,EAAE,CAAC;YACZ,MAAM;QACR;YACE,oCAAoC;YACpC,EAAE,GAAG,CAAC,CAAC;YACP,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC;YACZ,MAAM;IACV,CAAC;IACD,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;IACZ,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convolutionEffect.d.ts","sourceRoot":"","sources":["../src/convolutionEffect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC,GAAG,iBAAiB,CAE7G"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convolutionEffect.js","sourceRoot":"","sources":["../src/convolutionEffect.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,uBAAuB,CAAC,OAAkD;IACxF,OAAO,EAAE,IAAI,EAAE,mBAAmB,EAAE,GAAG,OAAO,EAAE,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropShadowEffect.d.ts","sourceRoot":"","sources":["../src/dropShadowEffect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAGxD,wBAAgB,sBAAsB,CAAC,OAAO,GAAE,QAAQ,CAAC,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAM,GAAG,gBAAgB,CAE/G"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Drop-shadow composite effect: tint the scene silhouette, blur it, offset it by angle/distance, then apply sourceMode compositing.
|
|
2
|
+
export function createDropShadowEffect(options = {}) {
|
|
3
|
+
return { kind: 'DropShadowEffect', ...options };
|
|
4
|
+
}
|
|
5
|
+
//# sourceMappingURL=dropShadowEffect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropShadowEffect.js","sourceRoot":"","sources":["../src/dropShadowEffect.ts"],"names":[],"mappings":"AAEA,oIAAoI;AACpI,MAAM,UAAU,sBAAsB,CAAC,UAAoD,EAAE;IAC3F,OAAO,EAAE,IAAI,EAAE,kBAAkB,EAAE,GAAG,OAAO,EAAE,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fills `out` with the 1D discrete Gaussian kernel weights for standard deviation `sigma`,
|
|
3
|
+
* normalized so the emitted weights sum to exactly 1. The kernel is symmetric with `out.length`
|
|
4
|
+
* set to `getGaussianKernelSize(sigma)` (an odd length), the center entry the largest. Because the
|
|
5
|
+
* kernel is truncated at radius `ceil(3 * sigma)`, the raw Gaussian samples are renormalized by
|
|
6
|
+
* their own truncated sum rather than the analytic 1/(sqrt(2π)·sigma) factor, so the discrete tail
|
|
7
|
+
* loss is absorbed and the taps a separable blur applies sum to 1. `sigma <= 0` yields a single
|
|
8
|
+
* unit weight (`[1]`), the identity kernel. Returns `out`.
|
|
9
|
+
*/
|
|
10
|
+
export declare function computeGaussianKernelWeights(sigma: number, out: number[]): number[];
|
|
11
|
+
/**
|
|
12
|
+
* Returns the length of the discrete Gaussian kernel for standard deviation `sigma`: the odd count
|
|
13
|
+
* `radius * 2 + 1` where `radius = ceil(3 * sigma)`. Three standard deviations capture ~99.7% of the
|
|
14
|
+
* Gaussian mass, the conventional truncation point. `sigma <= 0` returns 1 (the identity kernel).
|
|
15
|
+
*/
|
|
16
|
+
export declare function getGaussianKernelSize(sigma: number): number;
|
|
17
|
+
//# sourceMappingURL=gaussianKernel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gaussianKernel.d.ts","sourceRoot":"","sources":["../src/gaussianKernel.ts"],"names":[],"mappings":"AAOA;;;;;;;;GAQG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAqBnF;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAI3D"}
|