@vfx-js/effects 1.2.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 (136) 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/chromatic.d.ts +15 -0
  9. package/lib/cjs/chromatic.js +70 -0
  10. package/lib/cjs/chromatic.js.map +1 -0
  11. package/lib/cjs/colored-edges.d.ts +23 -0
  12. package/lib/cjs/colored-edges.js +88 -0
  13. package/lib/cjs/colored-edges.js.map +1 -0
  14. package/lib/cjs/dither.d.ts +24 -0
  15. package/lib/cjs/dither.js +120 -0
  16. package/lib/cjs/dither.js.map +1 -0
  17. package/lib/cjs/duotone.d.ts +17 -0
  18. package/lib/cjs/duotone.js +62 -0
  19. package/lib/cjs/duotone.js.map +1 -0
  20. package/lib/cjs/glitch.d.ts +13 -0
  21. package/lib/cjs/glitch.js +108 -0
  22. package/lib/cjs/glitch.js.map +1 -0
  23. package/lib/cjs/gradient-map.d.ts +25 -0
  24. package/lib/cjs/gradient-map.js +154 -0
  25. package/lib/cjs/gradient-map.js.map +1 -0
  26. package/lib/cjs/hue-shift.d.ts +11 -0
  27. package/lib/cjs/hue-shift.js +65 -0
  28. package/lib/cjs/hue-shift.js.map +1 -0
  29. package/lib/cjs/index.d.ts +20 -0
  30. package/lib/cjs/index.js +43 -1
  31. package/lib/cjs/index.js.map +1 -1
  32. package/lib/cjs/matrix.d.ts +135 -0
  33. package/lib/cjs/matrix.js +593 -0
  34. package/lib/cjs/matrix.js.map +1 -0
  35. package/lib/cjs/package.json +1 -1
  36. package/lib/cjs/pattern-refraction.d.ts +31 -0
  37. package/lib/cjs/pattern-refraction.js +190 -0
  38. package/lib/cjs/pattern-refraction.js.map +1 -0
  39. package/lib/cjs/pixel-stretch.d.ts +21 -0
  40. package/lib/cjs/pixel-stretch.js +78 -0
  41. package/lib/cjs/pixel-stretch.js.map +1 -0
  42. package/lib/cjs/rainbow.d.ts +13 -0
  43. package/lib/cjs/rainbow.js +79 -0
  44. package/lib/cjs/rainbow.js.map +1 -0
  45. package/lib/cjs/rgb-glitch.d.ts +13 -0
  46. package/lib/cjs/rgb-glitch.js +79 -0
  47. package/lib/cjs/rgb-glitch.js.map +1 -0
  48. package/lib/cjs/rgb-shift.d.ts +13 -0
  49. package/lib/cjs/rgb-shift.js +76 -0
  50. package/lib/cjs/rgb-shift.js.map +1 -0
  51. package/lib/cjs/sinewave.d.ts +17 -0
  52. package/lib/cjs/sinewave.js +76 -0
  53. package/lib/cjs/sinewave.js.map +1 -0
  54. package/lib/cjs/slice-shift.d.ts +21 -0
  55. package/lib/cjs/slice-shift.js +75 -0
  56. package/lib/cjs/slice-shift.js.map +1 -0
  57. package/lib/cjs/tile-pixelate.d.ts +28 -0
  58. package/lib/cjs/tile-pixelate.js +168 -0
  59. package/lib/cjs/tile-pixelate.js.map +1 -0
  60. package/lib/cjs/tritone.d.ts +18 -0
  61. package/lib/cjs/tritone.js +67 -0
  62. package/lib/cjs/tritone.js.map +1 -0
  63. package/lib/cjs/vignette.d.ts +15 -0
  64. package/lib/cjs/vignette.js +59 -0
  65. package/lib/cjs/vignette.js.map +1 -0
  66. package/lib/cjs/warp.d.ts +22 -0
  67. package/lib/cjs/warp.js +92 -0
  68. package/lib/cjs/warp.js.map +1 -0
  69. package/lib/esm/_figma-common.d.ts +8 -0
  70. package/lib/esm/_figma-common.js +42 -0
  71. package/lib/esm/_figma-common.js.map +1 -0
  72. package/lib/esm/ascii.d.ts +137 -0
  73. package/lib/esm/ascii.js +478 -0
  74. package/lib/esm/ascii.js.map +1 -0
  75. package/lib/esm/chromatic.d.ts +15 -0
  76. package/lib/esm/chromatic.js +66 -0
  77. package/lib/esm/chromatic.js.map +1 -0
  78. package/lib/esm/colored-edges.d.ts +23 -0
  79. package/lib/esm/colored-edges.js +84 -0
  80. package/lib/esm/colored-edges.js.map +1 -0
  81. package/lib/esm/dither.d.ts +24 -0
  82. package/lib/esm/dither.js +116 -0
  83. package/lib/esm/dither.js.map +1 -0
  84. package/lib/esm/duotone.d.ts +17 -0
  85. package/lib/esm/duotone.js +58 -0
  86. package/lib/esm/duotone.js.map +1 -0
  87. package/lib/esm/glitch.d.ts +13 -0
  88. package/lib/esm/glitch.js +104 -0
  89. package/lib/esm/glitch.js.map +1 -0
  90. package/lib/esm/gradient-map.d.ts +25 -0
  91. package/lib/esm/gradient-map.js +150 -0
  92. package/lib/esm/gradient-map.js.map +1 -0
  93. package/lib/esm/hue-shift.d.ts +11 -0
  94. package/lib/esm/hue-shift.js +61 -0
  95. package/lib/esm/hue-shift.js.map +1 -0
  96. package/lib/esm/index.d.ts +20 -0
  97. package/lib/esm/index.js +20 -0
  98. package/lib/esm/index.js.map +1 -1
  99. package/lib/esm/matrix.d.ts +135 -0
  100. package/lib/esm/matrix.js +589 -0
  101. package/lib/esm/matrix.js.map +1 -0
  102. package/lib/esm/package.json +1 -1
  103. package/lib/esm/pattern-refraction.d.ts +31 -0
  104. package/lib/esm/pattern-refraction.js +186 -0
  105. package/lib/esm/pattern-refraction.js.map +1 -0
  106. package/lib/esm/pixel-stretch.d.ts +21 -0
  107. package/lib/esm/pixel-stretch.js +74 -0
  108. package/lib/esm/pixel-stretch.js.map +1 -0
  109. package/lib/esm/rainbow.d.ts +13 -0
  110. package/lib/esm/rainbow.js +75 -0
  111. package/lib/esm/rainbow.js.map +1 -0
  112. package/lib/esm/rgb-glitch.d.ts +13 -0
  113. package/lib/esm/rgb-glitch.js +75 -0
  114. package/lib/esm/rgb-glitch.js.map +1 -0
  115. package/lib/esm/rgb-shift.d.ts +13 -0
  116. package/lib/esm/rgb-shift.js +72 -0
  117. package/lib/esm/rgb-shift.js.map +1 -0
  118. package/lib/esm/sinewave.d.ts +17 -0
  119. package/lib/esm/sinewave.js +72 -0
  120. package/lib/esm/sinewave.js.map +1 -0
  121. package/lib/esm/slice-shift.d.ts +21 -0
  122. package/lib/esm/slice-shift.js +71 -0
  123. package/lib/esm/slice-shift.js.map +1 -0
  124. package/lib/esm/tile-pixelate.d.ts +28 -0
  125. package/lib/esm/tile-pixelate.js +164 -0
  126. package/lib/esm/tile-pixelate.js.map +1 -0
  127. package/lib/esm/tritone.d.ts +18 -0
  128. package/lib/esm/tritone.js +63 -0
  129. package/lib/esm/tritone.js.map +1 -0
  130. package/lib/esm/vignette.d.ts +15 -0
  131. package/lib/esm/vignette.js +55 -0
  132. package/lib/esm/vignette.js.map +1 -0
  133. package/lib/esm/warp.d.ts +22 -0
  134. package/lib/esm/warp.js +88 -0
  135. package/lib/esm/warp.js.map +1 -0
  136. package/package.json +1 -1
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HueShiftEffect = void 0;
4
+ const FRAG_HUE_SHIFT = `#version 300 es
5
+ precision highp float;
6
+ in vec2 uvContent;
7
+ out vec4 outColor;
8
+ uniform sampler2D src;
9
+ uniform vec4 srcRectUv;
10
+ uniform float shift;
11
+
12
+ vec4 readTex(vec2 c) {
13
+ if (c.x < 0.0 || c.x > 1.0 || c.y < 0.0 || c.y > 1.0) return vec4(0.0);
14
+ return texture(src, srcRectUv.xy + c * srcRectUv.zw);
15
+ }
16
+
17
+ vec3 hsv2rgb(vec3 c) {
18
+ vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
19
+ vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
20
+ return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
21
+ }
22
+
23
+ vec3 rgb2hsv(vec3 c) {
24
+ vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
25
+ vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
26
+ vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
27
+
28
+ float d = q.x - min(q.w, q.y);
29
+ float e = 1.0e-10;
30
+ return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
31
+ }
32
+
33
+ vec3 hueShift(vec3 rgb, float t) {
34
+ vec3 hsv = rgb2hsv(rgb);
35
+ hsv.x = fract(hsv.x + t);
36
+ return hsv2rgb(hsv);
37
+ }
38
+
39
+ void main (void) {
40
+ vec4 color = readTex(uvContent);
41
+ color.rgb = hueShift(color.rgb, shift);
42
+ outColor = color;
43
+ }
44
+ `;
45
+ const DEFAULT_PARAMS = { shift: 0.5 };
46
+ class HueShiftEffect {
47
+ constructor(initial = {}) {
48
+ this.params = { ...DEFAULT_PARAMS, ...initial };
49
+ }
50
+ setParams(updates) {
51
+ Object.assign(this.params, updates);
52
+ }
53
+ render(ctx) {
54
+ ctx.draw({
55
+ frag: FRAG_HUE_SHIFT,
56
+ uniforms: {
57
+ src: ctx.src,
58
+ shift: this.params.shift,
59
+ },
60
+ target: ctx.target,
61
+ });
62
+ }
63
+ }
64
+ exports.HueShiftEffect = HueShiftEffect;
65
+ //# 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,MAAa,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;AArBD,wCAqBC"}
@@ -1,12 +1,32 @@
1
+ export { ASCII_PRESETS, type AsciiCharRamp, type AsciiColor, AsciiEffect, type AsciiImageSource, type AsciiParams, type AsciiPresetName, } from "./ascii";
1
2
  export { BadJpegEffect, type BadJpegEffectOptions } from "./bad-jpeg";
2
3
  export { BloomEffect } from "./bloom";
4
+ export { ChromaticEffect, type ChromaticParams } from "./chromatic";
5
+ export { ColoredEdgesEffect, type ColoredEdgesParams, } from "./colored-edges";
3
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";
4
9
  export { FluidEffect } from "./fluid";
10
+ export { GlitchEffect, type GlitchParams } from "./glitch";
11
+ export { GradientMapEffect, type GradientMapMixSpace, type GradientMapParams, type GradientMapRepeat, } from "./gradient-map";
5
12
  export { HalftoneEffect, type HalftoneInkPresetName } from "./halftone";
13
+ export { HueShiftEffect, type HueShiftParams } from "./hue-shift";
6
14
  export { JPEGGlitchEffect, type JPEGGlitchParams } from "./jpeg-glitch";
15
+ export { MATRIX_GLYPHS, type MatrixColor, MatrixEffect, type MatrixGlyphs, type MatrixParams, } from "./matrix";
7
16
  export { ParticleEffect } from "./particle";
8
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";
9
20
  export { PixelateEffect } from "./pixelate";
10
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";
11
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";
12
31
  export { VoronoiEffect } from "./voronoi";
32
+ export { WarpEffect, type WarpParams, type WarpType } from "./warp";
package/lib/cjs/index.js CHANGED
@@ -1,28 +1,70 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VoronoiEffect = exports.ScanlineEffect = exports.PixelSortEffect = exports.PixelateEffect = exports.ParticleExplodeEffect = exports.ParticleEffect = exports.JPEGGlitchEffect = exports.HalftoneEffect = exports.FluidEffect = exports.DatamoshEffect = exports.BloomEffect = exports.BadJpegEffect = void 0;
3
+ exports.WarpEffect = exports.VoronoiEffect = exports.VignetteEffect = exports.TritoneEffect = exports.TilePixelateEffect = exports.SliceShiftEffect = exports.SinewaveEffect = exports.ScanlineEffect = exports.RgbShiftEffect = exports.RgbGlitchEffect = exports.RainbowEffect = exports.PixelSortEffect = exports.PixelateEffect = exports.PixelStretchEffect = exports.PatternRefractionEffect = exports.ParticleExplodeEffect = exports.ParticleEffect = exports.MatrixEffect = exports.MATRIX_GLYPHS = exports.JPEGGlitchEffect = exports.HueShiftEffect = exports.HalftoneEffect = exports.GradientMapEffect = exports.GlitchEffect = exports.FluidEffect = exports.DuotoneEffect = exports.DitherEffect = exports.DatamoshEffect = exports.ColoredEdgesEffect = exports.ChromaticEffect = exports.BloomEffect = exports.BadJpegEffect = exports.AsciiEffect = exports.ASCII_PRESETS = void 0;
4
+ var ascii_1 = require("./ascii");
5
+ Object.defineProperty(exports, "ASCII_PRESETS", { enumerable: true, get: function () { return ascii_1.ASCII_PRESETS; } });
6
+ Object.defineProperty(exports, "AsciiEffect", { enumerable: true, get: function () { return ascii_1.AsciiEffect; } });
4
7
  var bad_jpeg_1 = require("./bad-jpeg");
5
8
  Object.defineProperty(exports, "BadJpegEffect", { enumerable: true, get: function () { return bad_jpeg_1.BadJpegEffect; } });
6
9
  var bloom_1 = require("./bloom");
7
10
  Object.defineProperty(exports, "BloomEffect", { enumerable: true, get: function () { return bloom_1.BloomEffect; } });
11
+ var chromatic_1 = require("./chromatic");
12
+ Object.defineProperty(exports, "ChromaticEffect", { enumerable: true, get: function () { return chromatic_1.ChromaticEffect; } });
13
+ var colored_edges_1 = require("./colored-edges");
14
+ Object.defineProperty(exports, "ColoredEdgesEffect", { enumerable: true, get: function () { return colored_edges_1.ColoredEdgesEffect; } });
8
15
  var datamosh_1 = require("./datamosh");
9
16
  Object.defineProperty(exports, "DatamoshEffect", { enumerable: true, get: function () { return datamosh_1.DatamoshEffect; } });
17
+ var dither_1 = require("./dither");
18
+ Object.defineProperty(exports, "DitherEffect", { enumerable: true, get: function () { return dither_1.DitherEffect; } });
19
+ var duotone_1 = require("./duotone");
20
+ Object.defineProperty(exports, "DuotoneEffect", { enumerable: true, get: function () { return duotone_1.DuotoneEffect; } });
10
21
  var fluid_1 = require("./fluid");
11
22
  Object.defineProperty(exports, "FluidEffect", { enumerable: true, get: function () { return fluid_1.FluidEffect; } });
23
+ var glitch_1 = require("./glitch");
24
+ Object.defineProperty(exports, "GlitchEffect", { enumerable: true, get: function () { return glitch_1.GlitchEffect; } });
25
+ var gradient_map_1 = require("./gradient-map");
26
+ Object.defineProperty(exports, "GradientMapEffect", { enumerable: true, get: function () { return gradient_map_1.GradientMapEffect; } });
12
27
  var halftone_1 = require("./halftone");
13
28
  Object.defineProperty(exports, "HalftoneEffect", { enumerable: true, get: function () { return halftone_1.HalftoneEffect; } });
29
+ var hue_shift_1 = require("./hue-shift");
30
+ Object.defineProperty(exports, "HueShiftEffect", { enumerable: true, get: function () { return hue_shift_1.HueShiftEffect; } });
14
31
  var jpeg_glitch_1 = require("./jpeg-glitch");
15
32
  Object.defineProperty(exports, "JPEGGlitchEffect", { enumerable: true, get: function () { return jpeg_glitch_1.JPEGGlitchEffect; } });
33
+ var matrix_1 = require("./matrix");
34
+ Object.defineProperty(exports, "MATRIX_GLYPHS", { enumerable: true, get: function () { return matrix_1.MATRIX_GLYPHS; } });
35
+ Object.defineProperty(exports, "MatrixEffect", { enumerable: true, get: function () { return matrix_1.MatrixEffect; } });
16
36
  var particle_1 = require("./particle");
17
37
  Object.defineProperty(exports, "ParticleEffect", { enumerable: true, get: function () { return particle_1.ParticleEffect; } });
18
38
  var particle_explode_1 = require("./particle-explode");
19
39
  Object.defineProperty(exports, "ParticleExplodeEffect", { enumerable: true, get: function () { return particle_explode_1.ParticleExplodeEffect; } });
40
+ var pattern_refraction_1 = require("./pattern-refraction");
41
+ Object.defineProperty(exports, "PatternRefractionEffect", { enumerable: true, get: function () { return pattern_refraction_1.PatternRefractionEffect; } });
42
+ var pixel_stretch_1 = require("./pixel-stretch");
43
+ Object.defineProperty(exports, "PixelStretchEffect", { enumerable: true, get: function () { return pixel_stretch_1.PixelStretchEffect; } });
20
44
  var pixelate_1 = require("./pixelate");
21
45
  Object.defineProperty(exports, "PixelateEffect", { enumerable: true, get: function () { return pixelate_1.PixelateEffect; } });
22
46
  var pixelsort_1 = require("./pixelsort");
23
47
  Object.defineProperty(exports, "PixelSortEffect", { enumerable: true, get: function () { return pixelsort_1.PixelSortEffect; } });
48
+ var rainbow_1 = require("./rainbow");
49
+ Object.defineProperty(exports, "RainbowEffect", { enumerable: true, get: function () { return rainbow_1.RainbowEffect; } });
50
+ var rgb_glitch_1 = require("./rgb-glitch");
51
+ Object.defineProperty(exports, "RgbGlitchEffect", { enumerable: true, get: function () { return rgb_glitch_1.RgbGlitchEffect; } });
52
+ var rgb_shift_1 = require("./rgb-shift");
53
+ Object.defineProperty(exports, "RgbShiftEffect", { enumerable: true, get: function () { return rgb_shift_1.RgbShiftEffect; } });
24
54
  var scanline_1 = require("./scanline");
25
55
  Object.defineProperty(exports, "ScanlineEffect", { enumerable: true, get: function () { return scanline_1.ScanlineEffect; } });
56
+ var sinewave_1 = require("./sinewave");
57
+ Object.defineProperty(exports, "SinewaveEffect", { enumerable: true, get: function () { return sinewave_1.SinewaveEffect; } });
58
+ var slice_shift_1 = require("./slice-shift");
59
+ Object.defineProperty(exports, "SliceShiftEffect", { enumerable: true, get: function () { return slice_shift_1.SliceShiftEffect; } });
60
+ var tile_pixelate_1 = require("./tile-pixelate");
61
+ Object.defineProperty(exports, "TilePixelateEffect", { enumerable: true, get: function () { return tile_pixelate_1.TilePixelateEffect; } });
62
+ var tritone_1 = require("./tritone");
63
+ Object.defineProperty(exports, "TritoneEffect", { enumerable: true, get: function () { return tritone_1.TritoneEffect; } });
64
+ var vignette_1 = require("./vignette");
65
+ Object.defineProperty(exports, "VignetteEffect", { enumerable: true, get: function () { return vignette_1.VignetteEffect; } });
26
66
  var voronoi_1 = require("./voronoi");
27
67
  Object.defineProperty(exports, "VoronoiEffect", { enumerable: true, get: function () { return voronoi_1.VoronoiEffect; } });
68
+ var warp_1 = require("./warp");
69
+ Object.defineProperty(exports, "WarpEffect", { enumerable: true, get: function () { return warp_1.WarpEffect; } });
28
70
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,uCAAsE;AAA7D,yGAAA,aAAa,OAAA;AACtB,iCAAsC;AAA7B,oGAAA,WAAW,OAAA;AACpB,uCAKoB;AAHhB,0GAAA,cAAc,OAAA;AAIlB,iCAAsC;AAA7B,oGAAA,WAAW,OAAA;AACpB,uCAAwE;AAA/D,0GAAA,cAAc,OAAA;AACvB,6CAAwE;AAA/D,+GAAA,gBAAgB,OAAA;AACzB,uCAA4C;AAAnC,0GAAA,cAAc,OAAA;AACvB,uDAA2D;AAAlD,yHAAA,qBAAqB,OAAA;AAC9B,uCAA4C;AAAnC,0GAAA,cAAc,OAAA;AACvB,yCAKqB;AAHjB,4GAAA,eAAe,OAAA;AAInB,uCAA4C;AAAnC,0GAAA,cAAc,OAAA;AACvB,qCAA0C;AAAjC,wGAAA,aAAa,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,iCAQiB;AAPb,sGAAA,aAAa,OAAA;AAGb,oGAAA,WAAW,OAAA;AAKf,uCAAsE;AAA7D,yGAAA,aAAa,OAAA;AACtB,iCAAsC;AAA7B,oGAAA,WAAW,OAAA;AACpB,yCAAoE;AAA3D,4GAAA,eAAe,OAAA;AACxB,iDAGyB;AAFrB,mHAAA,kBAAkB,OAAA;AAGtB,uCAKoB;AAHhB,0GAAA,cAAc,OAAA;AAIlB,mCAA6E;AAApE,sGAAA,YAAY,OAAA;AACrB,qCAAyE;AAAhE,wGAAA,aAAa,OAAA;AACtB,iCAAsC;AAA7B,oGAAA,WAAW,OAAA;AACpB,mCAA2D;AAAlD,sGAAA,YAAY,OAAA;AACrB,+CAKwB;AAJpB,iHAAA,iBAAiB,OAAA;AAKrB,uCAAwE;AAA/D,0GAAA,cAAc,OAAA;AACvB,yCAAkE;AAAzD,2GAAA,cAAc,OAAA;AACvB,6CAAwE;AAA/D,+GAAA,gBAAgB,OAAA;AACzB,mCAMkB;AALd,uGAAA,aAAa,OAAA;AAEb,sGAAA,YAAY,OAAA;AAIhB,uCAA4C;AAAnC,0GAAA,cAAc,OAAA;AACvB,uDAA2D;AAAlD,yHAAA,qBAAqB,OAAA;AAC9B,2DAK8B;AAJ1B,6HAAA,uBAAuB,OAAA;AAK3B,iDAGyB;AAFrB,mHAAA,kBAAkB,OAAA;AAGtB,uCAA4C;AAAnC,0GAAA,cAAc,OAAA;AACvB,yCAKqB;AAHjB,4GAAA,eAAe,OAAA;AAInB,qCAA8D;AAArD,wGAAA,aAAa,OAAA;AACtB,2CAAqE;AAA5D,6GAAA,eAAe,OAAA;AACxB,yCAAkE;AAAzD,2GAAA,cAAc,OAAA;AACvB,uCAA4C;AAAnC,0GAAA,cAAc,OAAA;AACvB,uCAAiE;AAAxD,0GAAA,cAAc,OAAA;AACvB,6CAAwE;AAA/D,+GAAA,gBAAgB,OAAA;AACzB,iDAIyB;AAHrB,mHAAA,kBAAkB,OAAA;AAItB,qCAA8D;AAArD,wGAAA,aAAa,OAAA;AACtB,uCAAiE;AAAxD,0GAAA,cAAc,OAAA;AACvB,qCAA0C;AAAjC,wGAAA,aAAa,OAAA;AACtB,+BAAoE;AAA3D,kGAAA,UAAU,OAAA"}
@@ -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
+ }