@vfx-js/effects 1.1.0 → 1.3.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.
Files changed (142) hide show
  1. package/README.md +2 -0
  2. package/lib/cjs/_figma-common.d.ts +8 -0
  3. package/lib/cjs/_figma-common.js +46 -0
  4. package/lib/cjs/_figma-common.js.map +1 -0
  5. package/lib/cjs/ascii.d.ts +137 -0
  6. package/lib/cjs/ascii.js +482 -0
  7. package/lib/cjs/ascii.js.map +1 -0
  8. package/lib/cjs/bad-jpeg.d.ts +25 -0
  9. package/lib/cjs/bad-jpeg.js +221 -0
  10. package/lib/cjs/bad-jpeg.js.map +1 -0
  11. package/lib/cjs/chromatic.d.ts +15 -0
  12. package/lib/cjs/chromatic.js +70 -0
  13. package/lib/cjs/chromatic.js.map +1 -0
  14. package/lib/cjs/colored-edges.d.ts +23 -0
  15. package/lib/cjs/colored-edges.js +88 -0
  16. package/lib/cjs/colored-edges.js.map +1 -0
  17. package/lib/cjs/dither.d.ts +24 -0
  18. package/lib/cjs/dither.js +120 -0
  19. package/lib/cjs/dither.js.map +1 -0
  20. package/lib/cjs/duotone.d.ts +17 -0
  21. package/lib/cjs/duotone.js +62 -0
  22. package/lib/cjs/duotone.js.map +1 -0
  23. package/lib/cjs/glitch.d.ts +13 -0
  24. package/lib/cjs/glitch.js +108 -0
  25. package/lib/cjs/glitch.js.map +1 -0
  26. package/lib/cjs/gradient-map.d.ts +25 -0
  27. package/lib/cjs/gradient-map.js +154 -0
  28. package/lib/cjs/gradient-map.js.map +1 -0
  29. package/lib/cjs/hue-shift.d.ts +11 -0
  30. package/lib/cjs/hue-shift.js +65 -0
  31. package/lib/cjs/hue-shift.js.map +1 -0
  32. package/lib/cjs/index.d.ts +21 -0
  33. package/lib/cjs/index.js +45 -1
  34. package/lib/cjs/index.js.map +1 -1
  35. package/lib/cjs/matrix.d.ts +135 -0
  36. package/lib/cjs/matrix.js +593 -0
  37. package/lib/cjs/matrix.js.map +1 -0
  38. package/lib/cjs/package.json +2 -2
  39. package/lib/cjs/pattern-refraction.d.ts +31 -0
  40. package/lib/cjs/pattern-refraction.js +190 -0
  41. package/lib/cjs/pattern-refraction.js.map +1 -0
  42. package/lib/cjs/pixel-stretch.d.ts +21 -0
  43. package/lib/cjs/pixel-stretch.js +78 -0
  44. package/lib/cjs/pixel-stretch.js.map +1 -0
  45. package/lib/cjs/rainbow.d.ts +13 -0
  46. package/lib/cjs/rainbow.js +79 -0
  47. package/lib/cjs/rainbow.js.map +1 -0
  48. package/lib/cjs/rgb-glitch.d.ts +13 -0
  49. package/lib/cjs/rgb-glitch.js +79 -0
  50. package/lib/cjs/rgb-glitch.js.map +1 -0
  51. package/lib/cjs/rgb-shift.d.ts +13 -0
  52. package/lib/cjs/rgb-shift.js +76 -0
  53. package/lib/cjs/rgb-shift.js.map +1 -0
  54. package/lib/cjs/sinewave.d.ts +17 -0
  55. package/lib/cjs/sinewave.js +76 -0
  56. package/lib/cjs/sinewave.js.map +1 -0
  57. package/lib/cjs/slice-shift.d.ts +21 -0
  58. package/lib/cjs/slice-shift.js +75 -0
  59. package/lib/cjs/slice-shift.js.map +1 -0
  60. package/lib/cjs/tile-pixelate.d.ts +28 -0
  61. package/lib/cjs/tile-pixelate.js +168 -0
  62. package/lib/cjs/tile-pixelate.js.map +1 -0
  63. package/lib/cjs/tritone.d.ts +18 -0
  64. package/lib/cjs/tritone.js +67 -0
  65. package/lib/cjs/tritone.js.map +1 -0
  66. package/lib/cjs/vignette.d.ts +15 -0
  67. package/lib/cjs/vignette.js +59 -0
  68. package/lib/cjs/vignette.js.map +1 -0
  69. package/lib/cjs/warp.d.ts +22 -0
  70. package/lib/cjs/warp.js +92 -0
  71. package/lib/cjs/warp.js.map +1 -0
  72. package/lib/esm/_figma-common.d.ts +8 -0
  73. package/lib/esm/_figma-common.js +42 -0
  74. package/lib/esm/_figma-common.js.map +1 -0
  75. package/lib/esm/ascii.d.ts +137 -0
  76. package/lib/esm/ascii.js +478 -0
  77. package/lib/esm/ascii.js.map +1 -0
  78. package/lib/esm/bad-jpeg.d.ts +25 -0
  79. package/lib/esm/bad-jpeg.js +217 -0
  80. package/lib/esm/bad-jpeg.js.map +1 -0
  81. package/lib/esm/chromatic.d.ts +15 -0
  82. package/lib/esm/chromatic.js +66 -0
  83. package/lib/esm/chromatic.js.map +1 -0
  84. package/lib/esm/colored-edges.d.ts +23 -0
  85. package/lib/esm/colored-edges.js +84 -0
  86. package/lib/esm/colored-edges.js.map +1 -0
  87. package/lib/esm/dither.d.ts +24 -0
  88. package/lib/esm/dither.js +116 -0
  89. package/lib/esm/dither.js.map +1 -0
  90. package/lib/esm/duotone.d.ts +17 -0
  91. package/lib/esm/duotone.js +58 -0
  92. package/lib/esm/duotone.js.map +1 -0
  93. package/lib/esm/glitch.d.ts +13 -0
  94. package/lib/esm/glitch.js +104 -0
  95. package/lib/esm/glitch.js.map +1 -0
  96. package/lib/esm/gradient-map.d.ts +25 -0
  97. package/lib/esm/gradient-map.js +150 -0
  98. package/lib/esm/gradient-map.js.map +1 -0
  99. package/lib/esm/hue-shift.d.ts +11 -0
  100. package/lib/esm/hue-shift.js +61 -0
  101. package/lib/esm/hue-shift.js.map +1 -0
  102. package/lib/esm/index.d.ts +21 -0
  103. package/lib/esm/index.js +21 -0
  104. package/lib/esm/index.js.map +1 -1
  105. package/lib/esm/matrix.d.ts +135 -0
  106. package/lib/esm/matrix.js +589 -0
  107. package/lib/esm/matrix.js.map +1 -0
  108. package/lib/esm/package.json +2 -2
  109. package/lib/esm/pattern-refraction.d.ts +31 -0
  110. package/lib/esm/pattern-refraction.js +186 -0
  111. package/lib/esm/pattern-refraction.js.map +1 -0
  112. package/lib/esm/pixel-stretch.d.ts +21 -0
  113. package/lib/esm/pixel-stretch.js +74 -0
  114. package/lib/esm/pixel-stretch.js.map +1 -0
  115. package/lib/esm/rainbow.d.ts +13 -0
  116. package/lib/esm/rainbow.js +75 -0
  117. package/lib/esm/rainbow.js.map +1 -0
  118. package/lib/esm/rgb-glitch.d.ts +13 -0
  119. package/lib/esm/rgb-glitch.js +75 -0
  120. package/lib/esm/rgb-glitch.js.map +1 -0
  121. package/lib/esm/rgb-shift.d.ts +13 -0
  122. package/lib/esm/rgb-shift.js +72 -0
  123. package/lib/esm/rgb-shift.js.map +1 -0
  124. package/lib/esm/sinewave.d.ts +17 -0
  125. package/lib/esm/sinewave.js +72 -0
  126. package/lib/esm/sinewave.js.map +1 -0
  127. package/lib/esm/slice-shift.d.ts +21 -0
  128. package/lib/esm/slice-shift.js +71 -0
  129. package/lib/esm/slice-shift.js.map +1 -0
  130. package/lib/esm/tile-pixelate.d.ts +28 -0
  131. package/lib/esm/tile-pixelate.js +164 -0
  132. package/lib/esm/tile-pixelate.js.map +1 -0
  133. package/lib/esm/tritone.d.ts +18 -0
  134. package/lib/esm/tritone.js +63 -0
  135. package/lib/esm/tritone.js.map +1 -0
  136. package/lib/esm/vignette.d.ts +15 -0
  137. package/lib/esm/vignette.js +55 -0
  138. package/lib/esm/vignette.js.map +1 -0
  139. package/lib/esm/warp.d.ts +22 -0
  140. package/lib/esm/warp.js +88 -0
  141. package/lib/esm/warp.js.map +1 -0
  142. package/package.json +2 -2
@@ -0,0 +1,104 @@
1
+ const FRAG_GLITCH = `#version 300 es
2
+ precision highp float;
3
+ in vec2 uvContent;
4
+ out vec4 outColor;
5
+ uniform sampler2D src;
6
+ uniform vec4 srcRectUv;
7
+ uniform float time;
8
+ uniform float intensity;
9
+
10
+ // Sample src at a content-space UV (0..1 over the element), remapped
11
+ // into the padded src buffer via srcRectUv.
12
+ vec4 sampleSrc(vec2 c) {
13
+ return texture(src, srcRectUv.xy + c * srcRectUv.zw);
14
+ }
15
+
16
+ // Like sampleSrc but transparent outside the content rect (preset autoCrop).
17
+ vec4 readTex(vec2 c) {
18
+ if (c.x < 0.0 || c.x > 1.0 || c.y < 0.0 || c.y > 1.0) return vec4(0.0);
19
+ return sampleSrc(c);
20
+ }
21
+
22
+ float nn(float y, float t) {
23
+ float n = (
24
+ sin(y * .07 + t * 8. + sin(y * .5 + t * 10.)) +
25
+ sin(y * .7 + t * 2. + sin(y * .3 + t * 8.)) * .7 +
26
+ sin(y * 1.1 + t * 2.8) * .4
27
+ );
28
+
29
+ n += sin(y * 124. + t * 100.7) * sin(y * 877. - t * 38.8) * .3;
30
+
31
+ return n;
32
+ }
33
+
34
+ void main (void) {
35
+ vec2 uv = uvContent;
36
+ vec4 color = readTex(uv);
37
+
38
+ float t = mod(time, 3.14 * 10.);
39
+
40
+ // Seed value
41
+ float v = fract(sin(t * 2.) * 700.);
42
+
43
+ if (abs(nn(uv.y, t)) < 1.2) {
44
+ v *= 0.01;
45
+ }
46
+
47
+ // Prepare for chromatic aberration
48
+ vec2 focus = vec2(0.5);
49
+ float d = v * 0.6 * intensity;
50
+ vec2 ruv = focus + (uv - focus) * (1. - d);
51
+ vec2 guv = focus + (uv - focus) * (1. - 2. * d);
52
+ vec2 buv = focus + (uv - focus) * (1. - 3. * d);
53
+
54
+ // Random Glitch
55
+ if (v > 0.1) {
56
+ // Randomize y
57
+ float y = floor(uv.y * 13. * sin(35. * t)) + 1.;
58
+ if (sin(36. * y * v) > 0.9) {
59
+ ruv.x = uv.x + sin(76. * y) * 0.1 * intensity;
60
+ guv.x = uv.x + sin(34. * y) * 0.1 * intensity;
61
+ buv.x = uv.x + sin(59. * y) * 0.1 * intensity;
62
+ }
63
+
64
+ // RGB Shift
65
+ v = pow(v * 1.5, 2.) * 0.15 * intensity;
66
+ color.rgb *= 0.3;
67
+ color.r += readTex(vec2(uv.x + sin(t * 123.45) * v, uv.y)).r;
68
+ color.g += readTex(vec2(uv.x + sin(t * 157.67) * v, uv.y)).g;
69
+ color.b += readTex(vec2(uv.x + sin(t * 143.67) * v, uv.y)).b;
70
+ }
71
+
72
+ // Compose chromatic aberration
73
+ if (abs(nn(uv.y, t)) > 1.1) {
74
+ color.r = color.r * 0.5 + color.r * sampleSrc(ruv).r;
75
+ color.g = color.g * 0.5 + color.g * sampleSrc(guv).g;
76
+ color.b = color.b * 0.5 + color.b * sampleSrc(buv).b;
77
+ color *= 2.;
78
+ }
79
+
80
+ outColor = color;
81
+ outColor.a = smoothstep(0.0, 0.8, max(color.r, max(color.g, color.b)));
82
+ }
83
+ `;
84
+ const DEFAULT_PARAMS = { speed: 1, intensity: 1 };
85
+ export class GlitchEffect {
86
+ constructor(initial = {}) {
87
+ this.params = { ...DEFAULT_PARAMS, ...initial };
88
+ }
89
+ setParams(updates) {
90
+ Object.assign(this.params, updates);
91
+ }
92
+ render(ctx) {
93
+ ctx.draw({
94
+ frag: FRAG_GLITCH,
95
+ uniforms: {
96
+ src: ctx.src,
97
+ time: ctx.time * this.params.speed,
98
+ intensity: this.params.intensity,
99
+ },
100
+ target: ctx.target,
101
+ });
102
+ }
103
+ }
104
+ //# sourceMappingURL=glitch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glitch.js","sourceRoot":"","sources":["../../src/glitch.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkFnB,CAAC;AASF,MAAM,cAAc,GAAiB,EAAE,KAAK,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;AAEhE,MAAM,OAAO,YAAY;IAGrB,YAAY,UAAiC,EAAE;QAC3C,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,OAAO,EAAE,CAAC;IACpD,CAAC;IAED,SAAS,CAAC,OAA8B;QACpC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,CAAC;IAED,MAAM,CAAC,GAAkB;QACrB,GAAG,CAAC,IAAI,CAAC;YACL,IAAI,EAAE,WAAW;YACjB,QAAQ,EAAE;gBACN,GAAG,EAAE,GAAG,CAAC,GAAG;gBACZ,IAAI,EAAE,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK;gBAClC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS;aACnC;YACD,MAAM,EAAE,GAAG,CAAC,MAAM;SACrB,CAAC,CAAC;IACP,CAAC;CACJ"}
@@ -0,0 +1,25 @@
1
+ import type { Effect, EffectContext } from "@vfx-js/core";
2
+ export type GradientMapRepeat = "none" | "repeat" | "mirror";
3
+ export type GradientMapMixSpace = "srgb" | "linear" | "oklab";
4
+ export type GradientMapParams = {
5
+ /** Gradient color stops (2–8), evenly spaced over the luminance range. */
6
+ colors: string[];
7
+ /** Random luminance jitter before the lookup, in [0, 1]. */
8
+ scatter: number;
9
+ /** Shift the lookup position along the gradient, in [0, 1]. */
10
+ offset: number;
11
+ /** How the lookup folds back when out of range (none = clamp). */
12
+ repeat: GradientMapRepeat;
13
+ /** How many times the gradient repeats across the luminance range. */
14
+ frequency: number;
15
+ /** Color space used to interpolate the gradient. */
16
+ mixSpace: GradientMapMixSpace;
17
+ /** Animate the offset over time, in [-1, 1] (0 = static). */
18
+ speed: number;
19
+ };
20
+ export declare class GradientMapEffect implements Effect {
21
+ params: GradientMapParams;
22
+ constructor(initial?: Partial<GradientMapParams>);
23
+ setParams(updates: Partial<GradientMapParams>): void;
24
+ render(ctx: EffectContext): void;
25
+ }
@@ -0,0 +1,150 @@
1
+ import { parseHexColor } from "./_figma-common";
2
+ const MAX_STOPS = 8;
3
+ const FRAG_GRADIENT_MAP = `#version 300 es
4
+ precision highp float;
5
+ in vec2 uvContent;
6
+ out vec4 outColor;
7
+ uniform sampler2D src;
8
+ uniform vec4 srcRectUv;
9
+ uniform vec3 colors[${MAX_STOPS}];
10
+ uniform int colorCount;
11
+ uniform float scatter;
12
+ uniform float offset;
13
+ uniform int repeatType;
14
+ uniform float frequency;
15
+ uniform int mixSpace;
16
+ uniform float time;
17
+
18
+ float hash12(vec2 p) {
19
+ vec3 p3 = fract(vec3(p.xyx) * 0.1031);
20
+ p3 += dot(p3, p3.yzx + 33.33);
21
+ return fract((p3.x + p3.y) * p3.z);
22
+ }
23
+
24
+ vec3 srgb2lin(vec3 c) { return pow(max(c, 0.0), vec3(2.2)); }
25
+ // Clamp first: OKLab interpolation can leave the gamut, and pow() of a
26
+ // negative value is NaN (renders as garbage/magenta).
27
+ vec3 lin2srgb(vec3 c) { return pow(max(c, 0.0), vec3(1.0 / 2.2)); }
28
+
29
+ vec3 lin2oklab(vec3 c) {
30
+ float l = 0.4122214708 * c.r + 0.5363325363 * c.g + 0.0514459929 * c.b;
31
+ float m = 0.2119034982 * c.r + 0.6806995451 * c.g + 0.1073969566 * c.b;
32
+ float s = 0.0883024619 * c.r + 0.2817188376 * c.g + 0.6299787005 * c.b;
33
+ vec3 lms = pow(max(vec3(l, m, s), 0.0), vec3(1.0 / 3.0));
34
+ return vec3(
35
+ 0.2104542553 * lms.x + 0.7936177850 * lms.y - 0.0040720468 * lms.z,
36
+ 1.9779984951 * lms.x - 2.4285922050 * lms.y + 0.4505937099 * lms.z,
37
+ 0.0259040371 * lms.x + 0.7827717662 * lms.y - 0.8086757660 * lms.z
38
+ );
39
+ }
40
+ vec3 oklab2lin(vec3 lab) {
41
+ float l_ = lab.x + 0.3963377774 * lab.y + 0.2158037573 * lab.z;
42
+ float m_ = lab.x - 0.1055613458 * lab.y - 0.0638541728 * lab.z;
43
+ float s_ = lab.x - 0.0894841775 * lab.y - 1.2914855480 * lab.z;
44
+ vec3 lms = vec3(l_, m_, s_);
45
+ lms = lms * lms * lms;
46
+ return vec3(
47
+ 4.0767416621 * lms.x - 3.3077115913 * lms.y + 0.2309699292 * lms.z,
48
+ -1.2684380046 * lms.x + 2.6097574011 * lms.y - 0.3413193965 * lms.z,
49
+ -0.0041960863 * lms.x - 0.7034186147 * lms.y + 1.7076147010 * lms.z
50
+ );
51
+ }
52
+
53
+ // Interpolate two sRGB colors in the selected space, returning sRGB.
54
+ vec3 mixColor(vec3 a, vec3 b, float t) {
55
+ if (mixSpace == 1) {
56
+ return lin2srgb(mix(srgb2lin(a), srgb2lin(b), t));
57
+ } else if (mixSpace == 2) {
58
+ vec3 oa = lin2oklab(srgb2lin(a));
59
+ vec3 ob = lin2oklab(srgb2lin(b));
60
+ return lin2srgb(oklab2lin(mix(oa, ob, t)));
61
+ }
62
+ return mix(a, b, t);
63
+ }
64
+
65
+ // Fold t into [0, 1] per the repeat mode (none = clamp).
66
+ float applyRepeat(float t) {
67
+ if (repeatType == 1) return fract(t);
68
+ if (repeatType == 2) return 1.0 - abs(1.0 - fract(t * 0.5) * 2.0);
69
+ return clamp(t, 0.0, 1.0);
70
+ }
71
+
72
+ vec3 sampleGradient(float t) {
73
+ float f = t * float(colorCount - 1);
74
+ int i = int(floor(f));
75
+ i = clamp(i, 0, colorCount - 2);
76
+ float frac = clamp(f - float(i), 0.0, 1.0);
77
+ return clamp(mixColor(colors[i], colors[i + 1], frac), 0.0, 1.0);
78
+ }
79
+
80
+ void main(void) {
81
+ vec4 tex = texture(src, srcRectUv.xy + uvContent * srcRectUv.zw);
82
+ float l = dot(tex.rgb, vec3(0.299, 0.587, 0.114));
83
+ // Hash in pixel space (gl_FragCoord); hash12 degenerates on tiny
84
+ // [0,1] uv inputs.
85
+ l += scatter * (hash12(gl_FragCoord.xy) - 0.5);
86
+
87
+ // offset (and time drift) advance one full cycle per unit, so a 0->1
88
+ // offset sweep runs (frequency) cycles.
89
+ float t = applyRepeat((l + offset + time) * frequency);
90
+ // Premultiply: the final blit is premultiplied, so non-zero rgb in
91
+ // transparent areas would add to the background as stray color.
92
+ outColor = vec4(sampleGradient(t) * tex.a, tex.a);
93
+ }
94
+ `;
95
+ const REPEAT_TYPES = {
96
+ none: 0,
97
+ repeat: 1,
98
+ mirror: 2,
99
+ };
100
+ const MIX_SPACES = {
101
+ srgb: 0,
102
+ linear: 1,
103
+ oklab: 2,
104
+ };
105
+ const DEFAULT_PARAMS = {
106
+ colors: ["#bbee00", "#3aa0ff", "#000000"],
107
+ scatter: 0,
108
+ offset: 0,
109
+ repeat: "mirror",
110
+ frequency: 1,
111
+ mixSpace: "srgb",
112
+ speed: 0,
113
+ };
114
+ export class GradientMapEffect {
115
+ constructor(initial = {}) {
116
+ this.params = { ...DEFAULT_PARAMS, ...initial };
117
+ }
118
+ setParams(updates) {
119
+ Object.assign(this.params, updates);
120
+ }
121
+ render(ctx) {
122
+ const p = this.params;
123
+ const stops = p.colors.length >= 2 ? p.colors : DEFAULT_PARAMS.colors;
124
+ const count = Math.min(MAX_STOPS, stops.length);
125
+ // Flatten the stops to a vec3[MAX_STOPS] array, padding with the last.
126
+ const flat = new Float32Array(MAX_STOPS * 3);
127
+ for (let i = 0; i < MAX_STOPS; i++) {
128
+ const [r, g, b] = parseHexColor(stops[Math.min(i, count - 1)]);
129
+ flat[i * 3] = r;
130
+ flat[i * 3 + 1] = g;
131
+ flat[i * 3 + 2] = b;
132
+ }
133
+ ctx.draw({
134
+ frag: FRAG_GRADIENT_MAP,
135
+ uniforms: {
136
+ src: ctx.src,
137
+ colors: flat,
138
+ colorCount: count,
139
+ scatter: Math.max(0, p.scatter),
140
+ offset: p.offset,
141
+ repeatType: REPEAT_TYPES[p.repeat] ?? 0,
142
+ frequency: p.frequency,
143
+ mixSpace: MIX_SPACES[p.mixSpace] ?? 0,
144
+ time: ctx.time * p.speed,
145
+ },
146
+ target: ctx.target,
147
+ });
148
+ }
149
+ }
150
+ //# sourceMappingURL=gradient-map.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gradient-map.js","sourceRoot":"","sources":["../../src/gradient-map.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,11 @@
1
+ import type { Effect, EffectContext } from "@vfx-js/core";
2
+ export type HueShiftParams = {
3
+ /** Hue rotation amount; `0..1` covers a full revolution. */
4
+ shift: number;
5
+ };
6
+ export declare class HueShiftEffect implements Effect {
7
+ params: HueShiftParams;
8
+ constructor(initial?: Partial<HueShiftParams>);
9
+ setParams(updates: Partial<HueShiftParams>): void;
10
+ render(ctx: EffectContext): void;
11
+ }
@@ -0,0 +1,61 @@
1
+ const FRAG_HUE_SHIFT = `#version 300 es
2
+ precision highp float;
3
+ in vec2 uvContent;
4
+ out vec4 outColor;
5
+ uniform sampler2D src;
6
+ uniform vec4 srcRectUv;
7
+ uniform float shift;
8
+
9
+ vec4 readTex(vec2 c) {
10
+ if (c.x < 0.0 || c.x > 1.0 || c.y < 0.0 || c.y > 1.0) return vec4(0.0);
11
+ return texture(src, srcRectUv.xy + c * srcRectUv.zw);
12
+ }
13
+
14
+ vec3 hsv2rgb(vec3 c) {
15
+ vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
16
+ vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
17
+ return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
18
+ }
19
+
20
+ vec3 rgb2hsv(vec3 c) {
21
+ vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
22
+ vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
23
+ vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
24
+
25
+ float d = q.x - min(q.w, q.y);
26
+ float e = 1.0e-10;
27
+ return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
28
+ }
29
+
30
+ vec3 hueShift(vec3 rgb, float t) {
31
+ vec3 hsv = rgb2hsv(rgb);
32
+ hsv.x = fract(hsv.x + t);
33
+ return hsv2rgb(hsv);
34
+ }
35
+
36
+ void main (void) {
37
+ vec4 color = readTex(uvContent);
38
+ color.rgb = hueShift(color.rgb, shift);
39
+ outColor = color;
40
+ }
41
+ `;
42
+ const DEFAULT_PARAMS = { shift: 0.5 };
43
+ export class HueShiftEffect {
44
+ constructor(initial = {}) {
45
+ this.params = { ...DEFAULT_PARAMS, ...initial };
46
+ }
47
+ setParams(updates) {
48
+ Object.assign(this.params, updates);
49
+ }
50
+ render(ctx) {
51
+ ctx.draw({
52
+ frag: FRAG_HUE_SHIFT,
53
+ uniforms: {
54
+ src: ctx.src,
55
+ shift: this.params.shift,
56
+ },
57
+ target: ctx.target,
58
+ });
59
+ }
60
+ }
61
+ //# sourceMappingURL=hue-shift.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hue-shift.js","sourceRoot":"","sources":["../../src/hue-shift.ts"],"names":[],"mappings":"AAIA,MAAM,cAAc,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwCtB,CAAC;AAOF,MAAM,cAAc,GAAmB,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;AAEtD,MAAM,OAAO,cAAc;IAGvB,YAAY,UAAmC,EAAE;QAC7C,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,OAAO,EAAE,CAAC;IACpD,CAAC;IAED,SAAS,CAAC,OAAgC;QACtC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,CAAC;IAED,MAAM,CAAC,GAAkB;QACrB,GAAG,CAAC,IAAI,CAAC;YACL,IAAI,EAAE,cAAc;YACpB,QAAQ,EAAE;gBACN,GAAG,EAAE,GAAG,CAAC,GAAG;gBACZ,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK;aAC3B;YACD,MAAM,EAAE,GAAG,CAAC,MAAM;SACrB,CAAC,CAAC;IACP,CAAC;CACJ"}
@@ -1,11 +1,32 @@
1
+ export { ASCII_PRESETS, type AsciiCharRamp, type AsciiColor, AsciiEffect, type AsciiImageSource, type AsciiParams, type AsciiPresetName, } from "./ascii";
2
+ export { BadJpegEffect, type BadJpegEffectOptions } from "./bad-jpeg";
1
3
  export { BloomEffect } from "./bloom";
4
+ export { ChromaticEffect, type ChromaticParams } from "./chromatic";
5
+ export { ColoredEdgesEffect, type ColoredEdgesParams, } from "./colored-edges";
2
6
  export { type DatamoshColorSpace, DatamoshEffect, type DatamoshParams, type DatamoshView, } from "./datamosh";
7
+ export { DitherEffect, type DitherParams, type DitherStyle } from "./dither";
8
+ export { DuotoneEffect, type DuotoneParams, type Rgba } from "./duotone";
3
9
  export { FluidEffect } from "./fluid";
10
+ export { GlitchEffect, type GlitchParams } from "./glitch";
11
+ export { GradientMapEffect, type GradientMapMixSpace, type GradientMapParams, type GradientMapRepeat, } from "./gradient-map";
4
12
  export { HalftoneEffect, type HalftoneInkPresetName } from "./halftone";
13
+ export { HueShiftEffect, type HueShiftParams } from "./hue-shift";
5
14
  export { JPEGGlitchEffect, type JPEGGlitchParams } from "./jpeg-glitch";
15
+ export { MATRIX_GLYPHS, type MatrixColor, MatrixEffect, type MatrixGlyphs, type MatrixParams, } from "./matrix";
6
16
  export { ParticleEffect } from "./particle";
7
17
  export { ParticleExplodeEffect } from "./particle-explode";
18
+ export { PatternRefractionEffect, type PatternRefractionParams, type RefractionEdgeWrap, type RefractionPattern, } from "./pattern-refraction";
19
+ export { PixelStretchEffect, type PixelStretchParams, } from "./pixel-stretch";
8
20
  export { PixelateEffect } from "./pixelate";
9
21
  export { type PixelSortDirection, PixelSortEffect, type PixelSortKey, type PixelSortParams, } from "./pixelsort";
22
+ export { RainbowEffect, type RainbowParams } from "./rainbow";
23
+ export { RgbGlitchEffect, type RgbGlitchParams } from "./rgb-glitch";
24
+ export { RgbShiftEffect, type RgbShiftParams } from "./rgb-shift";
10
25
  export { ScanlineEffect } from "./scanline";
26
+ export { SinewaveEffect, type SinewaveParams } from "./sinewave";
27
+ export { SliceShiftEffect, type SliceShiftParams } from "./slice-shift";
28
+ export { TilePixelateEffect, type TilePixelateParams, type TilePixelateShape, } from "./tile-pixelate";
29
+ export { TritoneEffect, type TritoneParams } from "./tritone";
30
+ export { VignetteEffect, type VignetteParams } from "./vignette";
11
31
  export { VoronoiEffect } from "./voronoi";
32
+ export { WarpEffect, type WarpParams, type WarpType } from "./warp";
package/lib/esm/index.js CHANGED
@@ -1,12 +1,33 @@
1
+ export { ASCII_PRESETS, AsciiEffect, } from "./ascii";
2
+ export { BadJpegEffect } from "./bad-jpeg";
1
3
  export { BloomEffect } from "./bloom";
4
+ export { ChromaticEffect } from "./chromatic";
5
+ export { ColoredEdgesEffect, } from "./colored-edges";
2
6
  export { DatamoshEffect, } from "./datamosh";
7
+ export { DitherEffect } from "./dither";
8
+ export { DuotoneEffect } from "./duotone";
3
9
  export { FluidEffect } from "./fluid";
10
+ export { GlitchEffect } from "./glitch";
11
+ export { GradientMapEffect, } from "./gradient-map";
4
12
  export { HalftoneEffect } from "./halftone";
13
+ export { HueShiftEffect } from "./hue-shift";
5
14
  export { JPEGGlitchEffect } from "./jpeg-glitch";
15
+ export { MATRIX_GLYPHS, MatrixEffect, } from "./matrix";
6
16
  export { ParticleEffect } from "./particle";
7
17
  export { ParticleExplodeEffect } from "./particle-explode";
18
+ export { PatternRefractionEffect, } from "./pattern-refraction";
19
+ export { PixelStretchEffect, } from "./pixel-stretch";
8
20
  export { PixelateEffect } from "./pixelate";
9
21
  export { PixelSortEffect, } from "./pixelsort";
22
+ export { RainbowEffect } from "./rainbow";
23
+ export { RgbGlitchEffect } from "./rgb-glitch";
24
+ export { RgbShiftEffect } from "./rgb-shift";
10
25
  export { ScanlineEffect } from "./scanline";
26
+ export { SinewaveEffect } from "./sinewave";
27
+ export { SliceShiftEffect } from "./slice-shift";
28
+ export { TilePixelateEffect, } from "./tile-pixelate";
29
+ export { TritoneEffect } from "./tritone";
30
+ export { VignetteEffect } from "./vignette";
11
31
  export { VoronoiEffect } from "./voronoi";
32
+ export { WarpEffect } from "./warp";
12
33
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAEH,cAAc,GAGjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,cAAc,EAA8B,MAAM,YAAY,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAyB,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAEH,eAAe,GAGlB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,aAAa,EAGb,WAAW,GAId,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,aAAa,EAA6B,MAAM,YAAY,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,eAAe,EAAwB,MAAM,aAAa,CAAC;AACpE,OAAO,EACH,kBAAkB,GAErB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAEH,cAAc,GAGjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,YAAY,EAAuC,MAAM,UAAU,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAiC,MAAM,WAAW,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,YAAY,EAAqB,MAAM,UAAU,CAAC;AAC3D,OAAO,EACH,iBAAiB,GAIpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,cAAc,EAA8B,MAAM,YAAY,CAAC;AACxE,OAAO,EAAE,cAAc,EAAuB,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAyB,MAAM,eAAe,CAAC;AACxE,OAAO,EACH,aAAa,EAEb,YAAY,GAGf,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EACH,uBAAuB,GAI1B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACH,kBAAkB,GAErB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAEH,eAAe,GAGlB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,aAAa,EAAsB,MAAM,WAAW,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAwB,MAAM,cAAc,CAAC;AACrE,OAAO,EAAE,cAAc,EAAuB,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAuB,MAAM,YAAY,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAyB,MAAM,eAAe,CAAC;AACxE,OAAO,EACH,kBAAkB,GAGrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,aAAa,EAAsB,MAAM,WAAW,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAuB,MAAM,YAAY,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAkC,MAAM,QAAQ,CAAC"}
@@ -0,0 +1,135 @@
1
+ import type { Effect, EffectContext } from "@vfx-js/core";
2
+ /** RGBA colour, each channel in [0, 1]. */
3
+ export type MatrixColor = [number, number, number, number];
4
+ /**
5
+ * Trail colour: a single {@link MatrixColor}, or an array of two or more
6
+ * colour stops forming a gradient along each drop's trail (first stop at the
7
+ * head, last at the tail end). Stops are interpolated in OKLCH.
8
+ */
9
+ export type MatrixTrailColor = MatrixColor | MatrixColor[];
10
+ /**
11
+ * The pool of glyphs rained down the columns. Pass a string (split per
12
+ * Unicode code point) or an array of single chars. The order is irrelevant
13
+ * — a random glyph is picked for every cell.
14
+ */
15
+ export type MatrixGlyphs = string | readonly string[];
16
+ /**
17
+ * Default glyph pool: half-width katakana (the look the film used) plus
18
+ * digits and a few symbols. Mirrored katakana isn't reproducible from a
19
+ * normal font, so these render upright.
20
+ */
21
+ export declare const MATRIX_GLYPHS = "\uFF8A\uFF8B\uFF8C\uFF8D\uFF8E\uFF71\uFF72\uFF73\uFF74\uFF75\uFF76\uFF77\uFF78\uFF79\uFF7A\uFF7B\uFF7C\uFF7D\uFF7E\uFF7F\uFF80\uFF81\uFF82\uFF83\uFF84\uFF85\uFF86\uFF87\uFF88\uFF89\uFF8F\uFF90\uFF91\uFF92\uFF93\uFF94\uFF95\uFF96\uFF97\uFF98\uFF99\uFF9A\uFF9B\uFF9C\uFF66\uFF9D0123456789Z:.\"=*+-<>|";
22
+ export type MatrixParams = {
23
+ /**
24
+ * Cell size in CSS px. A single number is a square cell; a
25
+ * `[width, height]` tuple sets the axes independently. Glyphs keep
26
+ * their native aspect (contain-fitted), so a non-square cell
27
+ * letterboxes rather than stretching.
28
+ */
29
+ grid: number | [number, number];
30
+ /**
31
+ * Glyph pool rained down the columns, picked at random per cell.
32
+ * Defaults to {@link MATRIX_GLYPHS}. Baked into the atlas at `init()`;
33
+ * change it (or `font` / `fontWeight`) then call
34
+ * {@link MatrixEffect.updateAtlas} (or re-add the effect) to rebuild.
35
+ */
36
+ glyphs?: MatrixGlyphs;
37
+ /** CSS font family used to render the glyph atlas. */
38
+ font: string;
39
+ /** CSS font weight for the glyph atlas (`"normal"`, `"bold"`, 100–900). */
40
+ fontWeight: string | number;
41
+ /**
42
+ * Character box aspect ratio (width / height). Omit to auto-measure it
43
+ * from the font (advance over em height).
44
+ */
45
+ charAspect?: number;
46
+ /**
47
+ * Trail colour — the classic phosphor green. Pass an array of two or
48
+ * more {@link MatrixColor} stops for a gradient along each drop's trail
49
+ * (first at the head, last at the tail end), interpolated in OKLCH. Pair
50
+ * with `tailFade: 0` to fade purely via the gradient.
51
+ */
52
+ color: MatrixTrailColor;
53
+ /** Leading-glyph colour at the head of each stream (usually near-white). */
54
+ headColor: MatrixColor;
55
+ /** Cell backdrop behind the rain, non-premultiplied. */
56
+ background: MatrixColor;
57
+ /** Base fall speed in cells per second. Per-column randomised ±50%. */
58
+ speed: number;
59
+ /** Trail length in cells (how far the trail extends behind the head). */
60
+ tail: number;
61
+ /**
62
+ * How much the trail dims toward its tail, in `[0, 1]`. `1` is the
63
+ * classic bright-head / dim-tail falloff; `0` keeps the whole trail at
64
+ * full brightness so you control the fade yourself via the colour
65
+ * gradient (e.g. a `color` stop fading to transparent or black).
66
+ */
67
+ tailFade: number;
68
+ /**
69
+ * Drop spawn rate: how many new falling streams are born per second in
70
+ * each column. Higher values spawn drops frequently (a busy, dense
71
+ * downpour — drops overlap into near-continuous streams); lower values
72
+ * leave long gaps between drops (sparse, intermittent rain).
73
+ */
74
+ birthRate: number;
75
+ /** Glyph reshuffle rate in changes per second (`0` = static glyphs). */
76
+ glyphSpeed: number;
77
+ /** Overall gain on the rain brightness. */
78
+ brightness: number;
79
+ /**
80
+ * Contrast of the source luminance, pivoting around mid-grey (0.5).
81
+ * `1` leaves the input unchanged; `< 1` flattens it toward grey; `> 1`
82
+ * deepens the split between dark and bright regions, so the picture
83
+ * reads more sharply through the rain.
84
+ */
85
+ contrast: number;
86
+ /** Flip the source luminance (rain shows through dark areas instead). */
87
+ invert: boolean;
88
+ /**
89
+ * Random seed for the rain pattern (per-column speed/phase and the glyph
90
+ * sequence). Any number; the same seed always reproduces the same
91
+ * pattern, so pin it (with {@link VFX.setTime}) for deterministic
92
+ * snapshots / visual regression tests. `0` is the default look.
93
+ */
94
+ seed: number;
95
+ };
96
+ /**
97
+ * "Digital rain" / Matrix-movie effect.
98
+ *
99
+ * @example
100
+ * ```ts
101
+ * vfx.add(el, { effect: new MatrixEffect({ grid: [12, 16] }) });
102
+ * vfx.add(el, { effect: new MatrixEffect({ glyphs: "01", color: [0, 1, 0, 1] }) });
103
+ * ```
104
+ *
105
+ * Splits the element into a grid and rains a random glyph down each column,
106
+ * with a bright leading tip and a fading green trail. The source image's
107
+ * grayscale is multiplied into the rain, so the picture emerges from the
108
+ * falling characters.
109
+ *
110
+ * `grid`, `color`, `headColor`, `background`, `speed`, `tail`, `tailFade`,
111
+ * `birthRate`, `glyphSpeed`, `brightness`, `contrast`, `invert`, and `seed`
112
+ * are live (read every frame). `glyphs` / `font` / `fontWeight` / `charAspect` are
113
+ * baked into the atlas at `init()` — after changing them via `setParams`,
114
+ * call {@link MatrixEffect.updateAtlas} (or re-add the effect) to rebuild.
115
+ */
116
+ export declare class MatrixEffect implements Effect {
117
+ #private;
118
+ constructor(initial?: Partial<MatrixParams>);
119
+ setParams(updates: Partial<MatrixParams>): void;
120
+ init(ctx: EffectContext): Promise<void>;
121
+ /**
122
+ * Rebuild the atlas from the current params, applying changes to the
123
+ * baked fields (`glyphs` / `font` / `fontWeight` / `charAspect`) without
124
+ * removing and re-adding the effect. Async — it may load fonts. No-op
125
+ * before `init()`.
126
+ *
127
+ * Allocates a fresh atlas texture and disposes the previous one once the
128
+ * swap is live, so repeated calls don't leak. Still rasterises the
129
+ * atlas, so prefer occasional calls (e.g. on a settings change) over
130
+ * per-frame use.
131
+ */
132
+ updateAtlas(): Promise<void>;
133
+ render(ctx: EffectContext): void;
134
+ dispose(): void;
135
+ }