textmode.filters.js 1.2.3 → 1.2.4-beta.1

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 (35) hide show
  1. package/README.md +24 -1
  2. package/dist/textmode.filters.esm.js +1 -1
  3. package/dist/textmode.filters.umd.js +1 -1
  4. package/dist/types/builtins/catalog.d.ts +163 -0
  5. package/dist/types/builtins/color-adjustment/brightness.d.ts +28 -0
  6. package/dist/types/builtins/color-adjustment/contrast.d.ts +28 -0
  7. package/dist/types/builtins/color-adjustment/grayscale.d.ts +14 -0
  8. package/dist/types/builtins/color-adjustment/hueRotate.d.ts +30 -0
  9. package/dist/types/builtins/color-adjustment/invert.d.ts +1 -0
  10. package/dist/types/builtins/color-adjustment/posterize.d.ts +31 -0
  11. package/dist/types/builtins/color-adjustment/saturation.d.ts +28 -0
  12. package/dist/types/builtins/color-adjustment/sepia.d.ts +14 -0
  13. package/dist/types/builtins/color-adjustment/threshold.d.ts +14 -0
  14. package/dist/types/builtins/definition.d.ts +26 -0
  15. package/dist/types/builtins/distortion/chromaticAberration.d.ts +40 -0
  16. package/dist/types/builtins/distortion/gridDistortion.d.ts +101 -0
  17. package/dist/types/builtins/distortion/pixelate.d.ts +28 -0
  18. package/dist/types/builtins/stylization/bloom.d.ts +55 -0
  19. package/dist/types/builtins/stylization/crtMattias.d.ts +52 -0
  20. package/dist/types/builtins/stylization/filmGrain.d.ts +64 -0
  21. package/dist/types/builtins/stylization/glitch.d.ts +28 -0
  22. package/dist/types/builtins/stylization/scanlines.d.ts +75 -0
  23. package/dist/types/builtins/stylization/vignette.d.ts +52 -0
  24. package/dist/types/global.d.ts +6 -0
  25. package/dist/types/index.d.ts +26 -37
  26. package/dist/types/plugin/FiltersPlugin.d.ts +7 -0
  27. package/dist/types/public/augmentations.d.ts +18 -0
  28. package/dist/types/public/filter-types.d.ts +20 -0
  29. package/dist/types/runtime/FilterRegistry.d.ts +26 -0
  30. package/dist/types/runtime/FilterRenderer.d.ts +26 -0
  31. package/dist/types/runtime/FilterScheduler.d.ts +35 -0
  32. package/dist/types/runtime/TextmodeFilterManager.d.ts +52 -0
  33. package/dist/types/runtime/types.d.ts +22 -0
  34. package/package.json +24 -67
  35. package/dist/types/types.d.ts +0 -638
package/README.md CHANGED
@@ -15,7 +15,7 @@ Use built-in treatments to refine a scene, tune their parameters as it runs, or
15
15
 
16
16
  ## Features
17
17
 
18
- - **Fourteen built-in effects** - Color adjustment, distortion, CRT, glitch, bloom, scanlines, vignette, grain, and related treatments
18
+ - **Eighteen built-in effects** - Invert, grayscale, sepia, threshold, color adjustment, distortion, CRT, glitch, bloom, scanlines, vignette, and grain
19
19
  - **GPU-native processing** - Execute every effect as a WebGL2 fragment-shader pass over rendered textmode textures
20
20
  - **Scoped and stackable pipelines** - Apply ordered effects to individual layers, the composited scene, or the final presentation stage
21
21
  - **Typed parameter control** - Configure effects through numeric shorthand or named option objects with documented defaults
@@ -40,6 +40,29 @@ Use it to apply and tune GPU filters interactively while your sketch runs.
40
40
  Follow the [official installation guide](https://code.textmode.art/docs/installation) to install
41
41
  `textmode.filters.js` alongside `textmode.js` with npm or browser-ready UMD bundles.
42
42
 
43
+ Version 2 requires `textmode.js` 0.18.x. Install `FiltersPlugin` before using `t.filter()`,
44
+ `layer.filter()`, `t.filters`, `t.layers.filters`, or `t.finalDraw()`:
45
+
46
+ ```js
47
+ import { textmode } from 'textmode.js';
48
+ import { FiltersPlugin } from 'textmode.filters.js';
49
+
50
+ const t = textmode.create({ plugins: [FiltersPlugin] });
51
+ t.draw(() => {
52
+ t.background(0);
53
+ t.filter('grayscale', 0.8);
54
+ });
55
+ ```
56
+
57
+ ### Migration from 1.x
58
+
59
+ | Before | After |
60
+ | --- | --- |
61
+ | Core effects available without a plugin | Install `FiltersPlugin` |
62
+ | Filter types imported from `textmode.js` | Import them from `textmode.filters.js` |
63
+ | `TextmodeFilterManager` from `textmode.js` | Import it from `textmode.filters.js` |
64
+ | `t.filter()` without an installed plugin | Create the instance with `plugins: [FiltersPlugin]` |
65
+
43
66
  ## Next steps
44
67
 
45
68
  - **[Read the filters documentation](https://code.textmode.art/docs/filters)** for filter scopes, parameters, and workflows.
@@ -1 +1 @@
1
- var e=new Array(128).fill(.5),o={name:"textmode.filters",version:"1.1.1",async install(o){o.filters.register("brightness","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float U0;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);vec3 B=A.rgb*U0;fragColor=vec4(B,A.a);}",{U0:["amount",1]}),o.filters.register("contrast","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float U0;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);vec3 B=(A.rgb-0.5)*U0+0.5;fragColor=vec4(B,A.a);}",{U0:["amount",1]}),o.filters.register("hueRotate","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float U1;in vec2 v_uv;out vec4 fragColor;float A(float B,float C,float D){if(D<0.)D+=1.;if(D>1.)D-=1.;if(D<1./6.)return B+(C-B)*6.*D;if(D<1./2.)return C;if(D<2./3.)return B+(C-B)*(2./3.-D)*6.;return B;}vec3 E(vec3 F){float G=max(max(F.r,F.g),F.b);float H=min(min(F.r,F.g),F.b);float I=G-H;vec3 J=vec3(0.);J.z=(G+H)/2.;if(I==0.){J.x=0.;J.y=0.;}else{J.y=J.z<0.5?I/(G+H):I/(2.-G-H);if(F.r==G){J.x=(F.g-F.b)/I+(F.g<F.b?6.:0.);}else if(F.g==G){J.x=(F.b-F.r)/I+2.;}else{J.x=(F.r-F.g)/I+4.;}J.x/=6.;}return J;}vec3 K(vec3 J){float L=J.x;float M=J.y;float N=J.z;if(M==0.){return vec3(N);}float C=N<0.5?N*(1.+M):N+M-N*M;float B=2.*N-C;float O=A(B,C,L+1./3.);float P=A(B,C,L);float Q=A(B,C,L-1./3.);return vec3(O,P,Q);}void main(){vec4 F=texture(u_texture,v_uv);vec3 J=E(F.rgb);J.x=fract(J.x+U1/360.);vec3 R=K(J);fragColor=vec4(R,F.a);}",{U1:["angle",0]}),o.filters.register("glitch","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float U0;in vec2 v_uv;out vec4 fragColor;float A(vec2 B){return fract(sin(dot(B.xy,vec2(12.9898,78.233)))*43758.5453);}void main(){vec2 C=v_uv;float D=U0*0.1;float E=floor(C.y*20.);float F=A(vec2(E,floor(U0*100.)));if(F>0.7){C.x+=(F-0.7)*D*2.;}float G=D*0.02;vec2 H=C+vec2(G,0.);vec2 I=C;vec2 J=C-vec2(G,0.);float K=texture(u_texture,H).r;float L=texture(u_texture,I).g;float M=texture(u_texture,J).b;float N=texture(u_texture,C).a;vec3 O=vec3(K,L,M);float P=sin(C.y*u_resolution.y*2.)*0.1*U0;O-=P;float Q=A(C+fract(U0))*0.1*U0;O+=Q;fragColor=vec4(O,N);}",{U0:["amount",0]}),o.filters.register("chromaticAberration","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float U0;uniform vec2 U4;in vec2 v_uv;out vec4 fragColor;void main(){vec2 A=1./u_resolution;vec2 B=U4*U0*A;float C=texture(u_texture,v_uv+B).r;vec4 D=texture(u_texture,v_uv);float E=D.g;float F=texture(u_texture,v_uv-B).b;float G=D.a;fragColor=vec4(C,E,F,G);}",{U0:["amount",5],U4:["direction",[1,0]]}),o.filters.register("pixelate","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float Uc;in vec2 v_uv;out vec4 fragColor;void main(){vec2 A=vec2(Uc)/u_resolution;vec2 B=floor(v_uv/A)*A+A*0.5;fragColor=texture(u_texture,B);}",{Uc:["pixelSize",4]}),o.filters.register("gridDistortion","#version 300 es\nprecision mediump float;in vec2 v_uv;out vec4 fragColor;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform vec2 U5;uniform vec2 U7;uniform vec2 U6;uniform float Ul[128];uniform float U8[128];uniform float Um;uniform float U9;const int A=128;const int B=128;void main(){vec2 C=v_uv*u_resolution;vec2 D=(C-U6)/U7;if(D.x<0.||D.x>1.||D.y<0.||D.y>1.){fragColor=vec4(0.);return;}int E=int(U5.x);int F=int(U5.y);float G=0.;for(int H=0;H<A;H++){if(H<E){float I=Ul[H];G+=0.1+I*Um;}}float J=0.;for(int K=0;K<B;K++){if(K<F){float L=U8[K];J+=0.1+L*U9;}}float M=D.x;float N=D.y;float O=0.;float P=0.;float Q=M*G;for(int H=0;H<A;H++){if(H<E){float I=Ul[H];float R=0.1+I*Um;if(Q<P+R){float S=(Q-P)/R;O=(float(H)+S)/float(E);break;}P+=R;}}float T=0.;float U=0.;float V=N*J;for(int K=0;K<B;K++){if(K<F){float L=U8[K];float W=0.1+L*U9;if(V<U+W){float S=(V-U)/W;T=(float(K)+S)/float(F);break;}U+=W;}}vec2 X=vec2(O,T);fragColor=texture(u_texture,X);}",{U5:["gridCellDimensions",[80,40]],U7:["gridPixelDimensions",[640,320]],U6:["gridOffsetDimensions",[0,0]],Ul:["widthFactors",e],U8:["heightFactors",e],Um:["widthVariationScale",.5],U9:["heightVariationScale",.5]}),o.filters.register("crtMattias","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float Uk;uniform float U3;uniform float Uf;in vec2 v_uv;out vec4 fragColor;vec3 A(vec2 B){vec3 C=pow(texture(u_texture,B).rgb,vec3(2.2));return C;}vec3 D(vec2 B,float E){vec4 F=E*vec4(-2.,-1.,1.,2.)/u_resolution.x;vec4 G=E*vec4(-2.,-1.,1.,2.)/u_resolution.y;vec3 H=vec3(0.);H+=A(B+vec2(F.x,G.x))*0.00366;H+=A(B+vec2(F.y,G.x))*0.01465;H+=A(B+vec2(0.,G.x))*0.02564;H+=A(B+vec2(F.z,G.x))*0.01465;H+=A(B+vec2(F.w,G.x))*0.00366;H+=A(B+vec2(F.x,G.y))*0.01465;H+=A(B+vec2(F.y,G.y))*0.05861;H+=A(B+vec2(0.,G.y))*0.09524;H+=A(B+vec2(F.z,G.y))*0.05861;H+=A(B+vec2(F.w,G.y))*0.01465;H+=A(B+vec2(F.x,0.))*0.02564;H+=A(B+vec2(F.y,0.))*0.09524;H+=A(B+vec2(0.,0.))*0.15018;H+=A(B+vec2(F.z,0.))*0.09524;H+=A(B+vec2(F.w,0.))*0.02564;H+=A(B+vec2(F.x,G.z))*0.01465;H+=A(B+vec2(F.y,G.z))*0.05861;H+=A(B+vec2(0.,G.z))*0.09524;H+=A(B+vec2(F.z,G.z))*0.05861;H+=A(B+vec2(F.w,G.z))*0.01465;H+=A(B+vec2(F.x,G.w))*0.00366;H+=A(B+vec2(F.y,G.w))*0.01465;H+=A(B+vec2(0.,G.w))*0.02564;H+=A(B+vec2(F.z,G.w))*0.01465;H+=A(B+vec2(F.w,G.w))*0.00366;return H;}float I(vec2 J){float K=12.9898;float L=78.233;float M=43758.5453;float N=dot(J.xy,vec2(K,L));float O=mod(N,3.14);return fract(sin(O)*M);}vec2 P(vec2 Q){Q=(Q-0.5)*2.;Q*=1.1;Q.x*=1.+pow((abs(Q.y)/5.),2.);Q.y*=1.+pow((abs(Q.x)/4.),2.);Q=(Q/2.)+0.5;Q=Q*0.92+0.04;return Q;}void main(){vec2 R=gl_FragCoord.xy;vec2 S=v_uv;vec2 Q=S;Q=mix(Q,P(Q),U3);vec3 T;float U=sin(0.1*Uk+Q.y*21.)*sin(0.23*Uk+Q.y*29.)*sin(0.3+0.11*Uk+Q.y*31.)*0.0017;float V=2.*mod(R.y,2.)/u_resolution.x;U+=V;T.r=1.*D(vec2(Q.x+0.0009,Q.y+0.0009),1.2).x+0.005;T.g=1.*D(vec2(Q.x+0.000,Q.y-0.0015),1.2).y+0.005;T.b=1.*D(vec2(Q.x-0.0015,Q.y+0.000),1.2).z+0.005;T.r+=0.2*D(vec2(Q.x+0.0009,Q.y+0.0009),2.25).x-0.005;T.g+=0.2*D(vec2(Q.x+0.000,Q.y-0.0015),1.75).y-0.005;T.b+=0.2*D(vec2(Q.x-0.0015,Q.y+0.000),1.25).z-0.005;float W=0.05;T.r+=W*(1.-0.299)*D(0.75*vec2(0.01,-0.027)+vec2(Q.x+0.001,Q.y+0.001),7.).x;T.g+=W*(1.-0.587)*D(0.75*vec2(-0.022,-0.02)+vec2(Q.x+0.000,Q.y-0.002),5.).y;T.b+=W*(1.-0.114)*D(0.75*vec2(-0.02,-0.)+vec2(Q.x-0.002,Q.y+0.000),3.).z;T=clamp(T*0.4+0.6*T*T*1.,0.,1.);float X=(0.+1.*16.*Q.x*Q.y*(1.-Q.x)*(1.-Q.y));X=pow(X,0.3);T*=vec3(X);T*=vec3(0.95,1.05,0.95);T=mix(T,T*T,0.3)*3.8;float Y=clamp(0.35+0.15*sin(3.5*(Uk*Uf)+Q.y*u_resolution.y*1.5),0.,1.);float C=pow(Y,0.9);T=T*vec3(C);T*=1.+0.0015*sin(300.*Uk);T*=1.-0.15*vec3(clamp((mod(R.x+V,2.)-1.)*2.,0.,1.));T*=vec3(1.)-0.25*vec3(I(Q+0.0001*Uk),I(Q+0.0001*Uk+0.3),I(Q+0.0001*Uk+0.5));T=pow(T,vec3(0.45));if(Q.x<0.||Q.x>1.)T*=0.;if(Q.y<0.||Q.y>1.)T*=0.;fragColor=vec4(T,1.);}",{U3:["curvature",.5],Uf:["scanSpeed",1],Uk:["time",0]}),o.filters.register("scanlines","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform float Uk;uniform float U2;uniform float Ua;uniform float Ui;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);float B=sin((v_uv.y*U2-Uk*Ui)*3.141592*2.);B=B*0.5+0.5;float C=1.-(Ua*(1.-B));fragColor=vec4(A.rgb*C,A.a);}",{U2:["count",300],u_lineWidth:["lineWidth",.5],Ua:["intensity",.75],Ui:["speed",1],Uk:["time",0]}),o.filters.register("vignette","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float U0;uniform float Uh;uniform float Ue;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);vec2 B=v_uv*2.-1.;float C=u_resolution.x/u_resolution.y;B.x*=C;float D=max(abs(B.x),abs(B.y));float E=length(B);float F=mix(D,E,Ue);float G=mix(max(C,1.),length(vec2(C,1.)),Ue);F/=G;float H=1.-U0;float I=H+Uh*0.5+0.01;float J=1.-smoothstep(H,I,F);vec3 K=A.rgb*J;fragColor=vec4(K,A.a);}",{U0:["amount",.5],Uh:["softness",.5],Ue:["roundness",.5]}),o.filters.register("bloom","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float Uj;uniform float Ua;uniform float Ud;in vec2 v_uv;out vec4 fragColor;float A(vec3 B){return dot(B,vec3(0.299,0.587,0.114));}vec3 C(vec3 B,float D){float E=A(B);float F=max(0.,E-D)/max(E,0.001);return B*F;}void main(){vec4 G=texture(u_texture,v_uv);vec2 H=1./u_resolution;vec3 I=vec3(0.);float J=0.;float K[7];K[0]=0.227027;K[1]=0.194594;K[2]=0.121621;K[3]=0.054054;K[4]=0.016216;K[5]=0.006216;K[6]=0.002216;for(int L=-6;L<=6;L++){float M=K[abs(L)];vec2 N=vec2(float(L)*Ud*H.x,0.);vec2 O=vec2(0.,float(L)*Ud*H.y);vec3 P=texture(u_texture,v_uv+N).rgb;I+=C(P,Uj)*M;if(L!=0){vec3 Q=texture(u_texture,v_uv+O).rgb;I+=C(Q,Uj)*M;J+=M;}J+=M;}float R=0.1;for(int L=1;L<=4;L++){float S=float(L)*Ud;vec2 T=vec2(S,S)*H;vec2 U=vec2(S,-S)*H;vec3 V=texture(u_texture,v_uv+T).rgb;vec3 W=texture(u_texture,v_uv-T).rgb;vec3 X=texture(u_texture,v_uv+U).rgb;vec3 Y=texture(u_texture,v_uv-U).rgb;float Z=R/float(L);I+=C(V,Uj)*Z;I+=C(W,Uj)*Z;I+=C(X,Uj)*Z;I+=C(Y,Uj)*Z;J+=Z*4.;}I/=J;vec3 a=G.rgb+I*Ua;fragColor=vec4(a,G.a);}",{Uj:["threshold",.5],Ua:["intensity",1],Ud:["radius",4]}),o.filters.register("filmGrain","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float Ua;uniform float Ug;uniform float Ui;uniform float Uk;in vec2 v_uv;out vec4 fragColor;float A(vec2 B){return fract(sin(dot(B,vec2(12.9898,78.233)))*43758.5453);}float C(vec2 D){vec2 E=floor(D);vec2 F=fract(D);vec2 G=F*F*(3.-2.*F);float H=A(E);float I=A(E+vec2(1.,0.));float J=A(E+vec2(0.,1.));float K=A(E+vec2(1.,1.));return mix(mix(H,I,G.x),mix(J,K,G.x),G.y);}void main(){vec4 L=texture(u_texture,v_uv);vec2 M=v_uv*u_resolution/Ug;M+=vec2(Uk*Ui*0.1);float N=C(M);float O=C(M*2.+vec2(100.));float P=C(M*4.+vec2(200.));float Q=N*0.6+O*0.3+P*0.1;Q=(Q-0.5)*Ua;float R=dot(L.rgb,vec3(0.299,0.587,0.114));float S=Q*(0.5+R*0.5);vec3 T=L.rgb+S;fragColor=vec4(T,L.a);}",{Ua:["intensity",.2],Ug:["size",2],Ui:["speed",1],Uk:["time",0]}),o.filters.register("saturation","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float U0;in vec2 v_uv;out vec4 fragColor;float A(float B,float C,float D){if(D<0.)D+=1.;if(D>1.)D-=1.;if(D<1./6.)return B+(C-B)*6.*D;if(D<1./2.)return C;if(D<2./3.)return B+(C-B)*(2./3.-D)*6.;return B;}vec3 E(vec3 F){float G=max(max(F.r,F.g),F.b);float H=min(min(F.r,F.g),F.b);float I=G-H;vec3 J=vec3(0.);J.z=(G+H)/2.;if(I==0.){J.x=0.;J.y=0.;}else{J.y=J.z<0.5?I/(G+H):I/(2.-G-H);if(F.r==G){J.x=(F.g-F.b)/I+(F.g<F.b?6.:0.);}else if(F.g==G){J.x=(F.b-F.r)/I+2.;}else{J.x=(F.r-F.g)/I+4.;}J.x/=6.;}return J;}vec3 K(vec3 J){float L=J.x;float M=J.y;float N=J.z;if(M==0.){return vec3(N);}float C=N<0.5?N*(1.+M):N+M-N*M;float B=2.*N-C;float O=A(B,C,L+1./3.);float P=A(B,C,L);float Q=A(B,C,L-1./3.);return vec3(O,P,Q);}void main(){vec4 F=texture(u_texture,v_uv);vec3 J=E(F.rgb);J.y=clamp(J.y*U0,0.,1.);vec3 R=K(J);fragColor=vec4(R,F.a);}",{U0:["amount",1]}),o.filters.register("posterize","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float Ub;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);vec3 B=floor(A.rgb*Ub)/Ub;fragColor=vec4(B,A.a);}",{Ub:["levels",4]})},async uninstall(e){e.filters.unregister("brightness"),e.filters.unregister("contrast"),e.filters.unregister("hueRotate"),e.filters.unregister("glitch"),e.filters.unregister("chromaticAberration"),e.filters.unregister("pixelate"),e.filters.unregister("gridDistortion"),e.filters.unregister("crtMattias"),e.filters.unregister("scanlines"),e.filters.unregister("vignette"),e.filters.unregister("bloom"),e.filters.unregister("filmGrain"),e.filters.unregister("saturation"),e.filters.unregister("posterize")}};"undefined"!=typeof window&&(window.FiltersPlugin=o);export{o as FiltersPlugin};
1
+ import"textmode.js";function e(e){const t=Object.entries(e.uniforms).map(([e,[t,r]])=>[e,t,r]),r=e.primary??t[0]?.[1];if(t.length>0&&void 0===r)throw new TypeError(`Builtin filter "${e.id}" requires an explicit primary parameter.`);const o={id:e.id,source:e.shader,uniforms:t,...void 0!==r?{primary:r}:{}};return Object.freeze(o)}var t=e({id:"brightness",shader:"#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float U0;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);vec3 B=A.rgb*U0;fragColor=vec4(B,A.a);}",primary:"amount",uniforms:{U0:["amount",1]}}),r=e({id:"contrast",shader:"#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float U0;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);vec3 B=(A.rgb-0.5)*U0+0.5;fragColor=vec4(B,A.a);}",primary:"amount",uniforms:{U0:["amount",1]}}),o=e({id:"grayscale",shader:"#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform float U0;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);float B=dot(A.rgb,vec3(0.299,0.587,0.114));fragColor=vec4(mix(A.rgb,vec3(B),U0),A.a);}",primary:"amount",uniforms:{U0:["amount",1]}}),i=e({id:"hueRotate",shader:"#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float U1;in vec2 v_uv;out vec4 fragColor;float A(float B,float C,float D){if(D<0.)D+=1.;if(D>1.)D-=1.;if(D<1./6.)return B+(C-B)*6.*D;if(D<1./2.)return C;if(D<2./3.)return B+(C-B)*(2./3.-D)*6.;return B;}vec3 E(vec3 F){float G=max(max(F.r,F.g),F.b);float H=min(min(F.r,F.g),F.b);float I=G-H;vec3 J=vec3(0.);J.z=(G+H)/2.;if(I==0.){J.x=0.;J.y=0.;}else{J.y=J.z<0.5?I/(G+H):I/(2.-G-H);if(F.r==G){J.x=(F.g-F.b)/I+(F.g<F.b?6.:0.);}else if(F.g==G){J.x=(F.b-F.r)/I+2.;}else{J.x=(F.r-F.g)/I+4.;}J.x/=6.;}return J;}vec3 K(vec3 J){float L=J.x;float M=J.y;float N=J.z;if(M==0.){return vec3(N);}float C=N<0.5?N*(1.+M):N+M-N*M;float B=2.*N-C;float O=A(B,C,L+1./3.);float P=A(B,C,L);float Q=A(B,C,L-1./3.);return vec3(O,P,Q);}void main(){vec4 F=texture(u_texture,v_uv);vec3 J=E(F.rgb);J.x=fract(J.x+U1/360.);vec3 R=K(J);fragColor=vec4(R,F.a);}",primary:"angle",uniforms:{U1:["angle",0]}}),a=e({id:"invert",shader:"#version 300 es\nprecision highp float;uniform sampler2D u_texture;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);fragColor=vec4(1.-A.rgb,A.a);}",uniforms:{}}),s=e({id:"posterize",shader:"#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float Ub;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);vec3 B=floor(A.rgb*Ub)/Ub;fragColor=vec4(B,A.a);}",primary:"levels",uniforms:{Ub:["levels",4]}}),n=e({id:"saturation",shader:"#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float U0;in vec2 v_uv;out vec4 fragColor;float A(float B,float C,float D){if(D<0.)D+=1.;if(D>1.)D-=1.;if(D<1./6.)return B+(C-B)*6.*D;if(D<1./2.)return C;if(D<2./3.)return B+(C-B)*(2./3.-D)*6.;return B;}vec3 E(vec3 F){float G=max(max(F.r,F.g),F.b);float H=min(min(F.r,F.g),F.b);float I=G-H;vec3 J=vec3(0.);J.z=(G+H)/2.;if(I==0.){J.x=0.;J.y=0.;}else{J.y=J.z<0.5?I/(G+H):I/(2.-G-H);if(F.r==G){J.x=(F.g-F.b)/I+(F.g<F.b?6.:0.);}else if(F.g==G){J.x=(F.b-F.r)/I+2.;}else{J.x=(F.r-F.g)/I+4.;}J.x/=6.;}return J;}vec3 K(vec3 J){float L=J.x;float M=J.y;float N=J.z;if(M==0.){return vec3(N);}float C=N<0.5?N*(1.+M):N+M-N*M;float B=2.*N-C;float O=A(B,C,L+1./3.);float P=A(B,C,L);float Q=A(B,C,L-1./3.);return vec3(O,P,Q);}void main(){vec4 F=texture(u_texture,v_uv);vec3 J=E(F.rgb);J.y=clamp(J.y*U0,0.,1.);vec3 R=K(J);fragColor=vec4(R,F.a);}",primary:"amount",uniforms:{U0:["amount",1]}}),u=e({id:"sepia",shader:"#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform float U0;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);vec3 B=vec3(dot(A.rgb,vec3(0.393,0.769,0.189)),dot(A.rgb,vec3(0.349,0.686,0.168)),dot(A.rgb,vec3(0.272,0.534,0.131)));fragColor=vec4(mix(A.rgb,B,U0),A.a);}",primary:"amount",uniforms:{U0:["amount",1]}}),f=e({id:"threshold",shader:"#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform float Uj;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);float B=step(Uj,dot(A.rgb,vec3(0.299,0.587,0.114)));fragColor=vec4(vec3(B),A.a);}",primary:"threshold",uniforms:{Uj:["threshold",.5]}}),v=e({id:"chromaticAberration",shader:"#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float U0;uniform vec2 U4;in vec2 v_uv;out vec4 fragColor;void main(){vec2 A=1./u_resolution;vec2 B=U4*U0*A;float C=texture(u_texture,v_uv+B).r;vec4 D=texture(u_texture,v_uv);float E=D.g;float F=texture(u_texture,v_uv-B).b;float G=D.a;fragColor=vec4(C,E,F,G);}",primary:"amount",uniforms:{U0:["amount",5],U4:["direction",[1,0]]}});function l(){return new Array(128).fill(.5)}var c=e({id:"gridDistortion",shader:"#version 300 es\nprecision mediump float;in vec2 v_uv;out vec4 fragColor;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform vec2 U5;uniform vec2 U7;uniform vec2 U6;uniform float Ul[128];uniform float U8[128];uniform float Um;uniform float U9;const int A=128;const int B=128;void main(){vec2 C=v_uv*u_resolution;vec2 D=(C-U6)/U7;if(D.x<0.||D.x>1.||D.y<0.||D.y>1.){fragColor=vec4(0.);return;}int E=int(U5.x);int F=int(U5.y);float G=0.;for(int H=0;H<A;H++){if(H<E){float I=Ul[H];G+=0.1+I*Um;}}float J=0.;for(int K=0;K<B;K++){if(K<F){float L=U8[K];J+=0.1+L*U9;}}float M=D.x;float N=D.y;float O=0.;float P=0.;float Q=M*G;for(int H=0;H<A;H++){if(H<E){float I=Ul[H];float R=0.1+I*Um;if(Q<P+R){float S=(Q-P)/R;O=(float(H)+S)/float(E);break;}P+=R;}}float T=0.;float U=0.;float V=N*J;for(int K=0;K<B;K++){if(K<F){float L=U8[K];float W=0.1+L*U9;if(V<U+W){float S=(V-U)/W;T=(float(K)+S)/float(F);break;}U+=W;}}vec2 X=vec2(O,T);fragColor=texture(u_texture,X);}",primary:"gridCellDimensions",uniforms:{U5:["gridCellDimensions",[80,40]],U7:["gridPixelDimensions",[640,320]],U6:["gridOffsetDimensions",[0,0]],Ul:["widthFactors",l()],U8:["heightFactors",l()],Um:["widthVariationScale",.5],U9:["heightVariationScale",.5]}}),h=e({id:"pixelate",shader:"#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float Uc;in vec2 v_uv;out vec4 fragColor;void main(){vec2 A=vec2(Uc)/u_resolution;vec2 B=floor(v_uv/A)*A+A*0.5;fragColor=texture(u_texture,B);}",primary:"pixelSize",uniforms:{Uc:["pixelSize",4]}}),m=e({id:"bloom",shader:"#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float Uj;uniform float Ua;uniform float Ud;in vec2 v_uv;out vec4 fragColor;float A(vec3 B){return dot(B,vec3(0.299,0.587,0.114));}vec3 C(vec3 B,float D){float E=A(B);float F=max(0.,E-D)/max(E,0.001);return B*F;}void main(){vec4 G=texture(u_texture,v_uv);vec2 H=1./u_resolution;vec3 I=vec3(0.);float J=0.;float K[7];K[0]=0.227027;K[1]=0.194594;K[2]=0.121621;K[3]=0.054054;K[4]=0.016216;K[5]=0.006216;K[6]=0.002216;for(int L=-6;L<=6;L++){float M=K[abs(L)];vec2 N=vec2(float(L)*Ud*H.x,0.);vec2 O=vec2(0.,float(L)*Ud*H.y);vec3 P=texture(u_texture,v_uv+N).rgb;I+=C(P,Uj)*M;if(L!=0){vec3 Q=texture(u_texture,v_uv+O).rgb;I+=C(Q,Uj)*M;J+=M;}J+=M;}float R=0.1;for(int L=1;L<=4;L++){float S=float(L)*Ud;vec2 T=vec2(S,S)*H;vec2 U=vec2(S,-S)*H;vec3 V=texture(u_texture,v_uv+T).rgb;vec3 W=texture(u_texture,v_uv-T).rgb;vec3 X=texture(u_texture,v_uv+U).rgb;vec3 Y=texture(u_texture,v_uv-U).rgb;float Z=R/float(L);I+=C(V,Uj)*Z;I+=C(W,Uj)*Z;I+=C(X,Uj)*Z;I+=C(Y,Uj)*Z;J+=Z*4.;}I/=J;vec3 a=G.rgb+I*Ua;fragColor=vec4(a,G.a);}",primary:"threshold",uniforms:{Uj:["threshold",.5],Ua:["intensity",1],Ud:["radius",4]}}),x=e({id:"crtMattias",shader:"#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float Uk;uniform float U3;uniform float Uf;in vec2 v_uv;out vec4 fragColor;vec3 A(vec2 B){vec3 C=pow(texture(u_texture,B).rgb,vec3(2.2));return C;}vec3 D(vec2 B,float E){vec4 F=E*vec4(-2.,-1.,1.,2.)/u_resolution.x;vec4 G=E*vec4(-2.,-1.,1.,2.)/u_resolution.y;vec3 H=vec3(0.);H+=A(B+vec2(F.x,G.x))*0.00366;H+=A(B+vec2(F.y,G.x))*0.01465;H+=A(B+vec2(0.,G.x))*0.02564;H+=A(B+vec2(F.z,G.x))*0.01465;H+=A(B+vec2(F.w,G.x))*0.00366;H+=A(B+vec2(F.x,G.y))*0.01465;H+=A(B+vec2(F.y,G.y))*0.05861;H+=A(B+vec2(0.,G.y))*0.09524;H+=A(B+vec2(F.z,G.y))*0.05861;H+=A(B+vec2(F.w,G.y))*0.01465;H+=A(B+vec2(F.x,0.))*0.02564;H+=A(B+vec2(F.y,0.))*0.09524;H+=A(B+vec2(0.,0.))*0.15018;H+=A(B+vec2(F.z,0.))*0.09524;H+=A(B+vec2(F.w,0.))*0.02564;H+=A(B+vec2(F.x,G.z))*0.01465;H+=A(B+vec2(F.y,G.z))*0.05861;H+=A(B+vec2(0.,G.z))*0.09524;H+=A(B+vec2(F.z,G.z))*0.05861;H+=A(B+vec2(F.w,G.z))*0.01465;H+=A(B+vec2(F.x,G.w))*0.00366;H+=A(B+vec2(F.y,G.w))*0.01465;H+=A(B+vec2(0.,G.w))*0.02564;H+=A(B+vec2(F.z,G.w))*0.01465;H+=A(B+vec2(F.w,G.w))*0.00366;return H;}float I(vec2 J){float K=12.9898;float L=78.233;float M=43758.5453;float N=dot(J.xy,vec2(K,L));float O=mod(N,3.14);return fract(sin(O)*M);}vec2 P(vec2 Q){Q=(Q-0.5)*2.;Q*=1.1;Q.x*=1.+pow((abs(Q.y)/5.),2.);Q.y*=1.+pow((abs(Q.x)/4.),2.);Q=(Q/2.)+0.5;Q=Q*0.92+0.04;return Q;}void main(){vec2 R=gl_FragCoord.xy;vec2 S=v_uv;vec2 Q=S;Q=mix(Q,P(Q),U3);vec3 T;float U=sin(0.1*Uk+Q.y*21.)*sin(0.23*Uk+Q.y*29.)*sin(0.3+0.11*Uk+Q.y*31.)*0.0017;float V=2.*mod(R.y,2.)/u_resolution.x;U+=V;T.r=1.*D(vec2(Q.x+0.0009,Q.y+0.0009),1.2).x+0.005;T.g=1.*D(vec2(Q.x+0.000,Q.y-0.0015),1.2).y+0.005;T.b=1.*D(vec2(Q.x-0.0015,Q.y+0.000),1.2).z+0.005;T.r+=0.2*D(vec2(Q.x+0.0009,Q.y+0.0009),2.25).x-0.005;T.g+=0.2*D(vec2(Q.x+0.000,Q.y-0.0015),1.75).y-0.005;T.b+=0.2*D(vec2(Q.x-0.0015,Q.y+0.000),1.25).z-0.005;float W=0.05;T.r+=W*(1.-0.299)*D(0.75*vec2(0.01,-0.027)+vec2(Q.x+0.001,Q.y+0.001),7.).x;T.g+=W*(1.-0.587)*D(0.75*vec2(-0.022,-0.02)+vec2(Q.x+0.000,Q.y-0.002),5.).y;T.b+=W*(1.-0.114)*D(0.75*vec2(-0.02,-0.)+vec2(Q.x-0.002,Q.y+0.000),3.).z;T=clamp(T*0.4+0.6*T*T*1.,0.,1.);float X=(0.+1.*16.*Q.x*Q.y*(1.-Q.x)*(1.-Q.y));X=pow(X,0.3);T*=vec3(X);T*=vec3(0.95,1.05,0.95);T=mix(T,T*T,0.3)*3.8;float Y=clamp(0.35+0.15*sin(3.5*(Uk*Uf)+Q.y*u_resolution.y*1.5),0.,1.);float C=pow(Y,0.9);T=T*vec3(C);T*=1.+0.0015*sin(300.*Uk);T*=1.-0.15*vec3(clamp((mod(R.x+V,2.)-1.)*2.,0.,1.));T*=vec3(1.)-0.25*vec3(I(Q+0.0001*Uk),I(Q+0.0001*Uk+0.3),I(Q+0.0001*Uk+0.5));T=pow(T,vec3(0.45));if(Q.x<0.||Q.x>1.)T*=0.;if(Q.y<0.||Q.y>1.)T*=0.;fragColor=vec4(T,1.);}",primary:"curvature",uniforms:{U3:["curvature",.5],Uf:["scanSpeed",1],Uk:["time",0]}}),p=e({id:"filmGrain",shader:"#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float Ua;uniform float Ug;uniform float Ui;uniform float Uk;in vec2 v_uv;out vec4 fragColor;float A(vec2 B){return fract(sin(dot(B,vec2(12.9898,78.233)))*43758.5453);}float C(vec2 D){vec2 E=floor(D);vec2 F=fract(D);vec2 G=F*F*(3.-2.*F);float H=A(E);float I=A(E+vec2(1.,0.));float J=A(E+vec2(0.,1.));float K=A(E+vec2(1.,1.));return mix(mix(H,I,G.x),mix(J,K,G.x),G.y);}void main(){vec4 L=texture(u_texture,v_uv);vec2 M=v_uv*u_resolution/Ug;M+=vec2(Uk*Ui*0.1);float N=C(M);float O=C(M*2.+vec2(100.));float P=C(M*4.+vec2(200.));float Q=N*0.6+O*0.3+P*0.1;Q=(Q-0.5)*Ua;float R=dot(L.rgb,vec3(0.299,0.587,0.114));float S=Q*(0.5+R*0.5);vec3 T=L.rgb+S;fragColor=vec4(T,L.a);}",primary:"intensity",uniforms:{Ua:["intensity",.2],Ug:["size",2],Ui:["speed",1],Uk:["time",0]}}),d=e({id:"glitch",shader:"#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float U0;in vec2 v_uv;out vec4 fragColor;float A(vec2 B){return fract(sin(dot(B.xy,vec2(12.9898,78.233)))*43758.5453);}void main(){vec2 C=v_uv;float D=U0*0.1;float E=floor(C.y*20.);float F=A(vec2(E,floor(U0*100.)));if(F>0.7){C.x+=(F-0.7)*D*2.;}float G=D*0.02;vec2 H=C+vec2(G,0.);vec2 I=C;vec2 J=C-vec2(G,0.);float K=texture(u_texture,H).r;float L=texture(u_texture,I).g;float M=texture(u_texture,J).b;float N=texture(u_texture,C).a;vec3 O=vec3(K,L,M);float P=sin(C.y*u_resolution.y*2.)*0.1*U0;O-=P;float Q=A(C+fract(U0))*0.1*U0;O+=Q;fragColor=vec4(O,N);}",primary:"amount",uniforms:{U0:["amount",0]}}),_=e({id:"scanlines",shader:"#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform float Uk;uniform float U2;uniform float Ua;uniform float Ui;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);float B=sin((v_uv.y*U2-Uk*Ui)*3.141592*2.);B=B*0.5+0.5;float C=1.-(Ua*(1.-B));fragColor=vec4(A.rgb*C,A.a);}",primary:"count",uniforms:{U2:["count",300],Ua:["intensity",.75],Ui:["speed",1],Uk:["time",0]}}),g=e({id:"vignette",shader:"#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float U0;uniform float Uh;uniform float Ue;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);vec2 B=v_uv*2.-1.;float C=u_resolution.x/u_resolution.y;B.x*=C;float D=max(abs(B.x),abs(B.y));float E=length(B);float F=mix(D,E,Ue);float G=mix(max(C,1.),length(vec2(C,1.)),Ue);F/=G;float H=1.-U0;float I=H+Uh*0.5+0.01;float J=1.-smoothstep(H,I,F);vec3 K=A.rgb*J;fragColor=vec4(K,A.a);}",primary:"amount",uniforms:{U0:["amount",.5],Uh:["softness",.5],Ue:["roundness",.5]}}),U=Object.freeze({invert:a,grayscale:o,sepia:u,threshold:f,brightness:t,contrast:r,saturation:n,hueRotate:i,posterize:s,chromaticAberration:v,pixelate:h,gridDistortion:c,glitch:d,crtMattias:x,scanlines:_,vignette:g,bloom:m,filmGrain:p}),y=class{t;o;i=/* @__PURE__ */new Map;u=!1;constructor(e,t,r){this.t=e,this.o=t;for(const o of r)this.i.set(o.id,{id:o.id,source:o.source,uniforms:o.uniforms,...o.primary?{primary:o.primary}:{}})}has(e){return this.i.has(e)}get(e){return this.i.get(e)}async register(e,t,r){const o="string"==typeof t?await this.t.createShader(this.o,t):t;this.u&&("string"==typeof t&&o.dispose(),this.v());const i=(a=r,Object.entries(a).map(([e,[t,r]])=>[e,t,r]));var a;this.l(e,{id:e,shader:o,uniforms:i,...i[0]?{primary:i[0][1]}:{}})}unregister(e){const t=this.i.get(e);return!!t&&(t.shader?.dispose(),this.i.delete(e),!0)}async initializeBuiltins(){const e=[];try{for(const[t,r]of this.i){if(!r.source||r.shader)continue;const o=await this.t.createShader(this.o,r.source);this.u&&(o.dispose(),this.v()),this.i.get(t)===r?(r.shader=o,e.push({descriptor:r,shader:o})):o.dispose()}}catch(t){for(const r of e.reverse())r.descriptor.shader===r.shader&&(r.descriptor.shader=void 0,this.u||r.shader.dispose());throw t}}dispose(){for(const e of this.i.values())e.shader?.dispose();this.i.clear(),this.u=!0}l(e,t){this.i.get(e)?.shader?.dispose(),this.i.set(e,t)}v(){if(this.u)throw new Error("TextmodeFilterManager has been disposed.")}},C=class{t;o;h=/* @__PURE__ */new WeakMap;m=/* @__PURE__ */new Set;p;constructor(e){this.t=e,this.o="#version 300 es\nlayout(location=0)in vec2 a_position;layout(location=1)in vec2 a_texCoord;out vec2 v_uv;void main(){v_uv=a_texCoord;gl_Position=vec4(a_position*2.,0.,1.);}"}get vertexSource(){return this.o}applyLayer(e,t,r){let o=this.h.get(e);return o||(o=this._(t.width,t.height),this.h.set(e,o)),this.U(t,r,o)}applyComposite(e,t){return this.p??=this._(e.width,e.height),this.U(e,t,this.p)}disposeLayer(e){const t=this.h.get(e);t&&this.C(t),this.h.delete(e)}dispose(){for(const e of[...this.m])this.C(e);this.h=/* @__PURE__ */new WeakMap,this.p=void 0}U(e,t,r){if(0===t.length)return e;this.F(r,e.width,e.height);let o=e;for(const i of t){const e=r[0]===o?r[1]:(r[1],r[0]);this.A(o,e,i.shader,this.B(i)),o=e}return o}A(e,t,r,o){this.t.push();let i=!1;try{t.begin(),i=!0,this.t.shader(r),this.t.setUniforms({u_texture:e.textures[0],u_resolution:[t.width,t.height],...o}),this.t.rect(t.width,t.height)}finally{try{i&&t.end()}finally{this.t.pop()}}}B(e){const t={};for(const[r,o,i]of e.uniforms){let a=i;if("number"==typeof e.params&&o===e.primary)a=e.params;else if(e.params&&"object"==typeof e.params&&o in e.params){const t=e.params[o];F(t)&&(a=t)}t[r]=a}return t}_(e,t){const r=[this.t.createFramebuffer({width:e,height:t,attachments:1,depth:!1}),this.t.createFramebuffer({width:e,height:t,attachments:1,depth:!1})];return this.m.add(r),r}F(e,t,r){e[0].width===t&&e[0].height===r||(e[0].resize(t,r),e[1].resize(t,r))}C(e){e[0].dispose(),e[1].dispose(),this.m.delete(e),this.p===e&&(this.p=void 0)}};function F(e){return"number"==typeof e||"boolean"==typeof e||Array.isArray(e)||e instanceof Float32Array||e instanceof Int32Array||"object"==typeof e&&null!==e}var A=class{D=0;H=!1;G=!1;J=[];T=[];L=/* @__PURE__ */new WeakMap;I=/* @__PURE__ */new Set;beginFrame(){this.D+=1;for(const e of this.I){const t=this.L.get(e);t&&(t.phase="draw")}this.H=!0}endFrame(){this.H=!1}queueLayer(e,t,r){const o=this.M(e);("postDraw"===o.phase?o.postQueue:o.drawQueue).push({name:t,params:r,frameToken:this.K()})}queueComposite(e,t){(this.G?this.T:this.J).push({name:e,params:t,frameToken:this.K()})}drainLayerDraw(e){return this.k(this.M(e).drawQueue)}drainLayerPostDraw(e){return this.k(this.M(e).postQueue)}setLayerPhase(e,t){this.M(e).phase=t}drainGlobal(){return this.k(this.J)}beginFinalDraw(){this.G=!0}endFinalDraw(){this.G=!1}drainFinal(){return this.k(this.T)}resetComposite(){this.J=[],this.T=[],this.G=!1}disposeLayer(e){this.L.delete(e),this.I.delete(e)}dispose(){this.J=[],this.T=[],this.L=/* @__PURE__ */new WeakMap,this.I.clear(),this.H=!1,this.G=!1}k(e){const t=this.D,r=[],o=[];for(const i of e)i.frameToken===t?r.push(i):i.frameToken>t&&o.push(i);return e.length=0,e.push(...o),r}M(e){let t=this.L.get(e);return t||(t={phase:"draw",drawQueue:[],postQueue:[]},this.L.set(e,t),this.I.add(e)),t}K(){return this.H?this.D:this.D+1}},B=class{t;P;O;S;N=()=>{};u=!1;constructor(e){this.t=e,this.S=new C(e),this.P=new y(e,this.S.vertexSource,Object.values(U)),this.O=new A}async register(e,t,r={}){if(this.v(),!e.trim())throw new TypeError("Filter id cannot be empty.");await this.P.register(e,t,r)}unregister(e){return this.P.unregister(e)}has(e){return this.P.has(e)}initializeBuiltins(){return this.v(),this.P.initializeBuiltins()}queueLayer(e,t,r){this.v(),this.O.queueLayer(e,t,r)}queueComposite(e,t){this.v(),this.O.queueComposite(e,t)}beginFrame(){this.O.beginFrame()}endFrame(){this.O.endFrame()}setFinalDrawCallback(e){this.N=e}transformLayer(e,t,r){if("resolved"===t){const t=this.j(r,this.O.drainLayerDraw(e),e,!1);return this.O.setLayerPhase(e,"postDraw"),t}try{return this.j(r,this.O.drainLayerPostDraw(e),e,!1)}finally{this.O.setLayerPhase(e,"draw")}}transformComposite(e){let t=e;try{t=this.j(t,this.O.drainGlobal(),void 0,!0),this.O.beginFinalDraw();try{this.N.call(this.t)}finally{this.O.endFinalDraw()}return this.j(t,this.O.drainFinal(),void 0,!0)}finally{this.O.resetComposite()}}disposeLayer(e){this.S.disposeLayer(e),this.O.disposeLayer(e)}dispose(){this.u||(this.P.dispose(),this.S.dispose(),this.O.dispose(),this.u=!0)}j(e,t,r,o){if(0===t.length)return e;const i=[];for(const a of t){const e=this.P.get(a.name);e?i.push(this.R(a.name,e,a.params)):console.warn(`[textmode.filters.js] Unknown filter: "${a.name}". Skipping.`)}return 0===i.length?e:o?this.S.applyComposite(e,i):this.S.applyLayer(r,e,i)}R(e,t,r){return{name:e,shader:this.W(t),uniforms:t.uniforms,params:r,...t.primary?{primary:t.primary}:{}}}W(e){if(e.shader)return e.shader;throw new Error("Filter shaders are not initialized. Wait for textmode setup to finish before drawing.")}v(){if(this.u)throw new Error("TextmodeFilterManager has been disposed.")}},D=/* @__PURE__ */new WeakMap,b={name:"textmode.filters",version:"1.2.4-beta.1",install(e,t){const r=D.get(e);r&&r.dispose();const o=new B(e);D.set(e,o),function(e,t){e.on("preSetup",()=>t.initializeBuiltins()),e.defineExtension("textmodifier","filter",{value:(e,r)=>t.queueComposite(e,r)}),e.defineExtension("textmodifier","filters",{get:()=>t}),e.defineExtension("textmodifier","finalDraw",{value:e=>{t.setFinalDrawCallback(e)}}),e.defineExtension("layerManager","filters",{get:()=>t});const r=t.queueLayer.bind(t);e.defineExtension("layer","filter",{value(e,t){r(this,e,t)}}),e.on("layerDisposed",e=>t.disposeLayer(e)),e.on("layerOutput",({layer:e,phase:r,output:o})=>t.transformLayer(e,r,o)),e.on("compositeOutput",e=>t.transformComposite(e)),e.on("preDraw",()=>t.beginFrame()),e.on("postDraw",()=>t.endFrame())}(t,o)},uninstall(e){D.get(e)?.dispose(),D.delete(e)}};"undefined"!=typeof window&&(window.FiltersPlugin=b);export{b as FiltersPlugin,B as TextmodeFilterManager};
@@ -1 +1 @@
1
- !function(e,o){"object"==typeof exports&&"undefined"!=typeof module?o(exports):"function"==typeof define&&define.amd?define(["exports"],o):o((e="undefined"!=typeof globalThis?globalThis:e||self).textmodeFilters={})}(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var o=new Array(128).fill(.5),t={name:"textmode.filters",version:"1.1.1",async install(e){e.filters.register("brightness","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float U0;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);vec3 B=A.rgb*U0;fragColor=vec4(B,A.a);}",{U0:["amount",1]}),e.filters.register("contrast","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float U0;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);vec3 B=(A.rgb-0.5)*U0+0.5;fragColor=vec4(B,A.a);}",{U0:["amount",1]}),e.filters.register("hueRotate","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float U1;in vec2 v_uv;out vec4 fragColor;float A(float B,float C,float D){if(D<0.)D+=1.;if(D>1.)D-=1.;if(D<1./6.)return B+(C-B)*6.*D;if(D<1./2.)return C;if(D<2./3.)return B+(C-B)*(2./3.-D)*6.;return B;}vec3 E(vec3 F){float G=max(max(F.r,F.g),F.b);float H=min(min(F.r,F.g),F.b);float I=G-H;vec3 J=vec3(0.);J.z=(G+H)/2.;if(I==0.){J.x=0.;J.y=0.;}else{J.y=J.z<0.5?I/(G+H):I/(2.-G-H);if(F.r==G){J.x=(F.g-F.b)/I+(F.g<F.b?6.:0.);}else if(F.g==G){J.x=(F.b-F.r)/I+2.;}else{J.x=(F.r-F.g)/I+4.;}J.x/=6.;}return J;}vec3 K(vec3 J){float L=J.x;float M=J.y;float N=J.z;if(M==0.){return vec3(N);}float C=N<0.5?N*(1.+M):N+M-N*M;float B=2.*N-C;float O=A(B,C,L+1./3.);float P=A(B,C,L);float Q=A(B,C,L-1./3.);return vec3(O,P,Q);}void main(){vec4 F=texture(u_texture,v_uv);vec3 J=E(F.rgb);J.x=fract(J.x+U1/360.);vec3 R=K(J);fragColor=vec4(R,F.a);}",{U1:["angle",0]}),e.filters.register("glitch","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float U0;in vec2 v_uv;out vec4 fragColor;float A(vec2 B){return fract(sin(dot(B.xy,vec2(12.9898,78.233)))*43758.5453);}void main(){vec2 C=v_uv;float D=U0*0.1;float E=floor(C.y*20.);float F=A(vec2(E,floor(U0*100.)));if(F>0.7){C.x+=(F-0.7)*D*2.;}float G=D*0.02;vec2 H=C+vec2(G,0.);vec2 I=C;vec2 J=C-vec2(G,0.);float K=texture(u_texture,H).r;float L=texture(u_texture,I).g;float M=texture(u_texture,J).b;float N=texture(u_texture,C).a;vec3 O=vec3(K,L,M);float P=sin(C.y*u_resolution.y*2.)*0.1*U0;O-=P;float Q=A(C+fract(U0))*0.1*U0;O+=Q;fragColor=vec4(O,N);}",{U0:["amount",0]}),e.filters.register("chromaticAberration","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float U0;uniform vec2 U4;in vec2 v_uv;out vec4 fragColor;void main(){vec2 A=1./u_resolution;vec2 B=U4*U0*A;float C=texture(u_texture,v_uv+B).r;vec4 D=texture(u_texture,v_uv);float E=D.g;float F=texture(u_texture,v_uv-B).b;float G=D.a;fragColor=vec4(C,E,F,G);}",{U0:["amount",5],U4:["direction",[1,0]]}),e.filters.register("pixelate","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float Uc;in vec2 v_uv;out vec4 fragColor;void main(){vec2 A=vec2(Uc)/u_resolution;vec2 B=floor(v_uv/A)*A+A*0.5;fragColor=texture(u_texture,B);}",{Uc:["pixelSize",4]}),e.filters.register("gridDistortion","#version 300 es\nprecision mediump float;in vec2 v_uv;out vec4 fragColor;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform vec2 U5;uniform vec2 U7;uniform vec2 U6;uniform float Ul[128];uniform float U8[128];uniform float Um;uniform float U9;const int A=128;const int B=128;void main(){vec2 C=v_uv*u_resolution;vec2 D=(C-U6)/U7;if(D.x<0.||D.x>1.||D.y<0.||D.y>1.){fragColor=vec4(0.);return;}int E=int(U5.x);int F=int(U5.y);float G=0.;for(int H=0;H<A;H++){if(H<E){float I=Ul[H];G+=0.1+I*Um;}}float J=0.;for(int K=0;K<B;K++){if(K<F){float L=U8[K];J+=0.1+L*U9;}}float M=D.x;float N=D.y;float O=0.;float P=0.;float Q=M*G;for(int H=0;H<A;H++){if(H<E){float I=Ul[H];float R=0.1+I*Um;if(Q<P+R){float S=(Q-P)/R;O=(float(H)+S)/float(E);break;}P+=R;}}float T=0.;float U=0.;float V=N*J;for(int K=0;K<B;K++){if(K<F){float L=U8[K];float W=0.1+L*U9;if(V<U+W){float S=(V-U)/W;T=(float(K)+S)/float(F);break;}U+=W;}}vec2 X=vec2(O,T);fragColor=texture(u_texture,X);}",{U5:["gridCellDimensions",[80,40]],U7:["gridPixelDimensions",[640,320]],U6:["gridOffsetDimensions",[0,0]],Ul:["widthFactors",o],U8:["heightFactors",o],Um:["widthVariationScale",.5],U9:["heightVariationScale",.5]}),e.filters.register("crtMattias","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float Uk;uniform float U3;uniform float Uf;in vec2 v_uv;out vec4 fragColor;vec3 A(vec2 B){vec3 C=pow(texture(u_texture,B).rgb,vec3(2.2));return C;}vec3 D(vec2 B,float E){vec4 F=E*vec4(-2.,-1.,1.,2.)/u_resolution.x;vec4 G=E*vec4(-2.,-1.,1.,2.)/u_resolution.y;vec3 H=vec3(0.);H+=A(B+vec2(F.x,G.x))*0.00366;H+=A(B+vec2(F.y,G.x))*0.01465;H+=A(B+vec2(0.,G.x))*0.02564;H+=A(B+vec2(F.z,G.x))*0.01465;H+=A(B+vec2(F.w,G.x))*0.00366;H+=A(B+vec2(F.x,G.y))*0.01465;H+=A(B+vec2(F.y,G.y))*0.05861;H+=A(B+vec2(0.,G.y))*0.09524;H+=A(B+vec2(F.z,G.y))*0.05861;H+=A(B+vec2(F.w,G.y))*0.01465;H+=A(B+vec2(F.x,0.))*0.02564;H+=A(B+vec2(F.y,0.))*0.09524;H+=A(B+vec2(0.,0.))*0.15018;H+=A(B+vec2(F.z,0.))*0.09524;H+=A(B+vec2(F.w,0.))*0.02564;H+=A(B+vec2(F.x,G.z))*0.01465;H+=A(B+vec2(F.y,G.z))*0.05861;H+=A(B+vec2(0.,G.z))*0.09524;H+=A(B+vec2(F.z,G.z))*0.05861;H+=A(B+vec2(F.w,G.z))*0.01465;H+=A(B+vec2(F.x,G.w))*0.00366;H+=A(B+vec2(F.y,G.w))*0.01465;H+=A(B+vec2(0.,G.w))*0.02564;H+=A(B+vec2(F.z,G.w))*0.01465;H+=A(B+vec2(F.w,G.w))*0.00366;return H;}float I(vec2 J){float K=12.9898;float L=78.233;float M=43758.5453;float N=dot(J.xy,vec2(K,L));float O=mod(N,3.14);return fract(sin(O)*M);}vec2 P(vec2 Q){Q=(Q-0.5)*2.;Q*=1.1;Q.x*=1.+pow((abs(Q.y)/5.),2.);Q.y*=1.+pow((abs(Q.x)/4.),2.);Q=(Q/2.)+0.5;Q=Q*0.92+0.04;return Q;}void main(){vec2 R=gl_FragCoord.xy;vec2 S=v_uv;vec2 Q=S;Q=mix(Q,P(Q),U3);vec3 T;float U=sin(0.1*Uk+Q.y*21.)*sin(0.23*Uk+Q.y*29.)*sin(0.3+0.11*Uk+Q.y*31.)*0.0017;float V=2.*mod(R.y,2.)/u_resolution.x;U+=V;T.r=1.*D(vec2(Q.x+0.0009,Q.y+0.0009),1.2).x+0.005;T.g=1.*D(vec2(Q.x+0.000,Q.y-0.0015),1.2).y+0.005;T.b=1.*D(vec2(Q.x-0.0015,Q.y+0.000),1.2).z+0.005;T.r+=0.2*D(vec2(Q.x+0.0009,Q.y+0.0009),2.25).x-0.005;T.g+=0.2*D(vec2(Q.x+0.000,Q.y-0.0015),1.75).y-0.005;T.b+=0.2*D(vec2(Q.x-0.0015,Q.y+0.000),1.25).z-0.005;float W=0.05;T.r+=W*(1.-0.299)*D(0.75*vec2(0.01,-0.027)+vec2(Q.x+0.001,Q.y+0.001),7.).x;T.g+=W*(1.-0.587)*D(0.75*vec2(-0.022,-0.02)+vec2(Q.x+0.000,Q.y-0.002),5.).y;T.b+=W*(1.-0.114)*D(0.75*vec2(-0.02,-0.)+vec2(Q.x-0.002,Q.y+0.000),3.).z;T=clamp(T*0.4+0.6*T*T*1.,0.,1.);float X=(0.+1.*16.*Q.x*Q.y*(1.-Q.x)*(1.-Q.y));X=pow(X,0.3);T*=vec3(X);T*=vec3(0.95,1.05,0.95);T=mix(T,T*T,0.3)*3.8;float Y=clamp(0.35+0.15*sin(3.5*(Uk*Uf)+Q.y*u_resolution.y*1.5),0.,1.);float C=pow(Y,0.9);T=T*vec3(C);T*=1.+0.0015*sin(300.*Uk);T*=1.-0.15*vec3(clamp((mod(R.x+V,2.)-1.)*2.,0.,1.));T*=vec3(1.)-0.25*vec3(I(Q+0.0001*Uk),I(Q+0.0001*Uk+0.3),I(Q+0.0001*Uk+0.5));T=pow(T,vec3(0.45));if(Q.x<0.||Q.x>1.)T*=0.;if(Q.y<0.||Q.y>1.)T*=0.;fragColor=vec4(T,1.);}",{U3:["curvature",.5],Uf:["scanSpeed",1],Uk:["time",0]}),e.filters.register("scanlines","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform float Uk;uniform float U2;uniform float Ua;uniform float Ui;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);float B=sin((v_uv.y*U2-Uk*Ui)*3.141592*2.);B=B*0.5+0.5;float C=1.-(Ua*(1.-B));fragColor=vec4(A.rgb*C,A.a);}",{U2:["count",300],u_lineWidth:["lineWidth",.5],Ua:["intensity",.75],Ui:["speed",1],Uk:["time",0]}),e.filters.register("vignette","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float U0;uniform float Uh;uniform float Ue;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);vec2 B=v_uv*2.-1.;float C=u_resolution.x/u_resolution.y;B.x*=C;float D=max(abs(B.x),abs(B.y));float E=length(B);float F=mix(D,E,Ue);float G=mix(max(C,1.),length(vec2(C,1.)),Ue);F/=G;float H=1.-U0;float I=H+Uh*0.5+0.01;float J=1.-smoothstep(H,I,F);vec3 K=A.rgb*J;fragColor=vec4(K,A.a);}",{U0:["amount",.5],Uh:["softness",.5],Ue:["roundness",.5]}),e.filters.register("bloom","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float Uj;uniform float Ua;uniform float Ud;in vec2 v_uv;out vec4 fragColor;float A(vec3 B){return dot(B,vec3(0.299,0.587,0.114));}vec3 C(vec3 B,float D){float E=A(B);float F=max(0.,E-D)/max(E,0.001);return B*F;}void main(){vec4 G=texture(u_texture,v_uv);vec2 H=1./u_resolution;vec3 I=vec3(0.);float J=0.;float K[7];K[0]=0.227027;K[1]=0.194594;K[2]=0.121621;K[3]=0.054054;K[4]=0.016216;K[5]=0.006216;K[6]=0.002216;for(int L=-6;L<=6;L++){float M=K[abs(L)];vec2 N=vec2(float(L)*Ud*H.x,0.);vec2 O=vec2(0.,float(L)*Ud*H.y);vec3 P=texture(u_texture,v_uv+N).rgb;I+=C(P,Uj)*M;if(L!=0){vec3 Q=texture(u_texture,v_uv+O).rgb;I+=C(Q,Uj)*M;J+=M;}J+=M;}float R=0.1;for(int L=1;L<=4;L++){float S=float(L)*Ud;vec2 T=vec2(S,S)*H;vec2 U=vec2(S,-S)*H;vec3 V=texture(u_texture,v_uv+T).rgb;vec3 W=texture(u_texture,v_uv-T).rgb;vec3 X=texture(u_texture,v_uv+U).rgb;vec3 Y=texture(u_texture,v_uv-U).rgb;float Z=R/float(L);I+=C(V,Uj)*Z;I+=C(W,Uj)*Z;I+=C(X,Uj)*Z;I+=C(Y,Uj)*Z;J+=Z*4.;}I/=J;vec3 a=G.rgb+I*Ua;fragColor=vec4(a,G.a);}",{Uj:["threshold",.5],Ua:["intensity",1],Ud:["radius",4]}),e.filters.register("filmGrain","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float Ua;uniform float Ug;uniform float Ui;uniform float Uk;in vec2 v_uv;out vec4 fragColor;float A(vec2 B){return fract(sin(dot(B,vec2(12.9898,78.233)))*43758.5453);}float C(vec2 D){vec2 E=floor(D);vec2 F=fract(D);vec2 G=F*F*(3.-2.*F);float H=A(E);float I=A(E+vec2(1.,0.));float J=A(E+vec2(0.,1.));float K=A(E+vec2(1.,1.));return mix(mix(H,I,G.x),mix(J,K,G.x),G.y);}void main(){vec4 L=texture(u_texture,v_uv);vec2 M=v_uv*u_resolution/Ug;M+=vec2(Uk*Ui*0.1);float N=C(M);float O=C(M*2.+vec2(100.));float P=C(M*4.+vec2(200.));float Q=N*0.6+O*0.3+P*0.1;Q=(Q-0.5)*Ua;float R=dot(L.rgb,vec3(0.299,0.587,0.114));float S=Q*(0.5+R*0.5);vec3 T=L.rgb+S;fragColor=vec4(T,L.a);}",{Ua:["intensity",.2],Ug:["size",2],Ui:["speed",1],Uk:["time",0]}),e.filters.register("saturation","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float U0;in vec2 v_uv;out vec4 fragColor;float A(float B,float C,float D){if(D<0.)D+=1.;if(D>1.)D-=1.;if(D<1./6.)return B+(C-B)*6.*D;if(D<1./2.)return C;if(D<2./3.)return B+(C-B)*(2./3.-D)*6.;return B;}vec3 E(vec3 F){float G=max(max(F.r,F.g),F.b);float H=min(min(F.r,F.g),F.b);float I=G-H;vec3 J=vec3(0.);J.z=(G+H)/2.;if(I==0.){J.x=0.;J.y=0.;}else{J.y=J.z<0.5?I/(G+H):I/(2.-G-H);if(F.r==G){J.x=(F.g-F.b)/I+(F.g<F.b?6.:0.);}else if(F.g==G){J.x=(F.b-F.r)/I+2.;}else{J.x=(F.r-F.g)/I+4.;}J.x/=6.;}return J;}vec3 K(vec3 J){float L=J.x;float M=J.y;float N=J.z;if(M==0.){return vec3(N);}float C=N<0.5?N*(1.+M):N+M-N*M;float B=2.*N-C;float O=A(B,C,L+1./3.);float P=A(B,C,L);float Q=A(B,C,L-1./3.);return vec3(O,P,Q);}void main(){vec4 F=texture(u_texture,v_uv);vec3 J=E(F.rgb);J.y=clamp(J.y*U0,0.,1.);vec3 R=K(J);fragColor=vec4(R,F.a);}",{U0:["amount",1]}),e.filters.register("posterize","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float Ub;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);vec3 B=floor(A.rgb*Ub)/Ub;fragColor=vec4(B,A.a);}",{Ub:["levels",4]})},async uninstall(e){e.filters.unregister("brightness"),e.filters.unregister("contrast"),e.filters.unregister("hueRotate"),e.filters.unregister("glitch"),e.filters.unregister("chromaticAberration"),e.filters.unregister("pixelate"),e.filters.unregister("gridDistortion"),e.filters.unregister("crtMattias"),e.filters.unregister("scanlines"),e.filters.unregister("vignette"),e.filters.unregister("bloom"),e.filters.unregister("filmGrain"),e.filters.unregister("saturation"),e.filters.unregister("posterize")}};"undefined"!=typeof window&&(window.FiltersPlugin=t),e.FiltersPlugin=t});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("textmode.js")):"function"==typeof define&&define.amd?define(["exports","textmode.js"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).textmodeFilters={},e.textmode)}(this,function(e,t){function r(e){const t=Object.entries(e.uniforms).map(([e,[t,r]])=>[e,t,r]),r=e.primary??t[0]?.[1];if(t.length>0&&void 0===r)throw new TypeError(`Builtin filter "${e.id}" requires an explicit primary parameter.`);const o={id:e.id,source:e.shader,uniforms:t,...void 0!==r?{primary:r}:{}};return Object.freeze(o)}Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var o=r({id:"brightness",shader:"#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float U0;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);vec3 B=A.rgb*U0;fragColor=vec4(B,A.a);}",primary:"amount",uniforms:{U0:["amount",1]}}),i=r({id:"contrast",shader:"#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float U0;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);vec3 B=(A.rgb-0.5)*U0+0.5;fragColor=vec4(B,A.a);}",primary:"amount",uniforms:{U0:["amount",1]}}),a=r({id:"grayscale",shader:"#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform float U0;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);float B=dot(A.rgb,vec3(0.299,0.587,0.114));fragColor=vec4(mix(A.rgb,vec3(B),U0),A.a);}",primary:"amount",uniforms:{U0:["amount",1]}}),s=r({id:"hueRotate",shader:"#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float U1;in vec2 v_uv;out vec4 fragColor;float A(float B,float C,float D){if(D<0.)D+=1.;if(D>1.)D-=1.;if(D<1./6.)return B+(C-B)*6.*D;if(D<1./2.)return C;if(D<2./3.)return B+(C-B)*(2./3.-D)*6.;return B;}vec3 E(vec3 F){float G=max(max(F.r,F.g),F.b);float H=min(min(F.r,F.g),F.b);float I=G-H;vec3 J=vec3(0.);J.z=(G+H)/2.;if(I==0.){J.x=0.;J.y=0.;}else{J.y=J.z<0.5?I/(G+H):I/(2.-G-H);if(F.r==G){J.x=(F.g-F.b)/I+(F.g<F.b?6.:0.);}else if(F.g==G){J.x=(F.b-F.r)/I+2.;}else{J.x=(F.r-F.g)/I+4.;}J.x/=6.;}return J;}vec3 K(vec3 J){float L=J.x;float M=J.y;float N=J.z;if(M==0.){return vec3(N);}float C=N<0.5?N*(1.+M):N+M-N*M;float B=2.*N-C;float O=A(B,C,L+1./3.);float P=A(B,C,L);float Q=A(B,C,L-1./3.);return vec3(O,P,Q);}void main(){vec4 F=texture(u_texture,v_uv);vec3 J=E(F.rgb);J.x=fract(J.x+U1/360.);vec3 R=K(J);fragColor=vec4(R,F.a);}",primary:"angle",uniforms:{U1:["angle",0]}}),n=r({id:"invert",shader:"#version 300 es\nprecision highp float;uniform sampler2D u_texture;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);fragColor=vec4(1.-A.rgb,A.a);}",uniforms:{}}),u=r({id:"posterize",shader:"#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float Ub;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);vec3 B=floor(A.rgb*Ub)/Ub;fragColor=vec4(B,A.a);}",primary:"levels",uniforms:{Ub:["levels",4]}}),f=r({id:"saturation",shader:"#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float U0;in vec2 v_uv;out vec4 fragColor;float A(float B,float C,float D){if(D<0.)D+=1.;if(D>1.)D-=1.;if(D<1./6.)return B+(C-B)*6.*D;if(D<1./2.)return C;if(D<2./3.)return B+(C-B)*(2./3.-D)*6.;return B;}vec3 E(vec3 F){float G=max(max(F.r,F.g),F.b);float H=min(min(F.r,F.g),F.b);float I=G-H;vec3 J=vec3(0.);J.z=(G+H)/2.;if(I==0.){J.x=0.;J.y=0.;}else{J.y=J.z<0.5?I/(G+H):I/(2.-G-H);if(F.r==G){J.x=(F.g-F.b)/I+(F.g<F.b?6.:0.);}else if(F.g==G){J.x=(F.b-F.r)/I+2.;}else{J.x=(F.r-F.g)/I+4.;}J.x/=6.;}return J;}vec3 K(vec3 J){float L=J.x;float M=J.y;float N=J.z;if(M==0.){return vec3(N);}float C=N<0.5?N*(1.+M):N+M-N*M;float B=2.*N-C;float O=A(B,C,L+1./3.);float P=A(B,C,L);float Q=A(B,C,L-1./3.);return vec3(O,P,Q);}void main(){vec4 F=texture(u_texture,v_uv);vec3 J=E(F.rgb);J.y=clamp(J.y*U0,0.,1.);vec3 R=K(J);fragColor=vec4(R,F.a);}",primary:"amount",uniforms:{U0:["amount",1]}}),v=r({id:"sepia",shader:"#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform float U0;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);vec3 B=vec3(dot(A.rgb,vec3(0.393,0.769,0.189)),dot(A.rgb,vec3(0.349,0.686,0.168)),dot(A.rgb,vec3(0.272,0.534,0.131)));fragColor=vec4(mix(A.rgb,B,U0),A.a);}",primary:"amount",uniforms:{U0:["amount",1]}}),l=r({id:"threshold",shader:"#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform float Uj;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);float B=step(Uj,dot(A.rgb,vec3(0.299,0.587,0.114)));fragColor=vec4(vec3(B),A.a);}",primary:"threshold",uniforms:{Uj:["threshold",.5]}}),c=r({id:"chromaticAberration",shader:"#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float U0;uniform vec2 U4;in vec2 v_uv;out vec4 fragColor;void main(){vec2 A=1./u_resolution;vec2 B=U4*U0*A;float C=texture(u_texture,v_uv+B).r;vec4 D=texture(u_texture,v_uv);float E=D.g;float F=texture(u_texture,v_uv-B).b;float G=D.a;fragColor=vec4(C,E,F,G);}",primary:"amount",uniforms:{U0:["amount",5],U4:["direction",[1,0]]}});function h(){return new Array(128).fill(.5)}var m=r({id:"gridDistortion",shader:"#version 300 es\nprecision mediump float;in vec2 v_uv;out vec4 fragColor;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform vec2 U5;uniform vec2 U7;uniform vec2 U6;uniform float Ul[128];uniform float U8[128];uniform float Um;uniform float U9;const int A=128;const int B=128;void main(){vec2 C=v_uv*u_resolution;vec2 D=(C-U6)/U7;if(D.x<0.||D.x>1.||D.y<0.||D.y>1.){fragColor=vec4(0.);return;}int E=int(U5.x);int F=int(U5.y);float G=0.;for(int H=0;H<A;H++){if(H<E){float I=Ul[H];G+=0.1+I*Um;}}float J=0.;for(int K=0;K<B;K++){if(K<F){float L=U8[K];J+=0.1+L*U9;}}float M=D.x;float N=D.y;float O=0.;float P=0.;float Q=M*G;for(int H=0;H<A;H++){if(H<E){float I=Ul[H];float R=0.1+I*Um;if(Q<P+R){float S=(Q-P)/R;O=(float(H)+S)/float(E);break;}P+=R;}}float T=0.;float U=0.;float V=N*J;for(int K=0;K<B;K++){if(K<F){float L=U8[K];float W=0.1+L*U9;if(V<U+W){float S=(V-U)/W;T=(float(K)+S)/float(F);break;}U+=W;}}vec2 X=vec2(O,T);fragColor=texture(u_texture,X);}",primary:"gridCellDimensions",uniforms:{U5:["gridCellDimensions",[80,40]],U7:["gridPixelDimensions",[640,320]],U6:["gridOffsetDimensions",[0,0]],Ul:["widthFactors",h()],U8:["heightFactors",h()],Um:["widthVariationScale",.5],U9:["heightVariationScale",.5]}}),d=r({id:"pixelate",shader:"#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float Uc;in vec2 v_uv;out vec4 fragColor;void main(){vec2 A=vec2(Uc)/u_resolution;vec2 B=floor(v_uv/A)*A+A*0.5;fragColor=texture(u_texture,B);}",primary:"pixelSize",uniforms:{Uc:["pixelSize",4]}}),p=r({id:"bloom",shader:"#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float Uj;uniform float Ua;uniform float Ud;in vec2 v_uv;out vec4 fragColor;float A(vec3 B){return dot(B,vec3(0.299,0.587,0.114));}vec3 C(vec3 B,float D){float E=A(B);float F=max(0.,E-D)/max(E,0.001);return B*F;}void main(){vec4 G=texture(u_texture,v_uv);vec2 H=1./u_resolution;vec3 I=vec3(0.);float J=0.;float K[7];K[0]=0.227027;K[1]=0.194594;K[2]=0.121621;K[3]=0.054054;K[4]=0.016216;K[5]=0.006216;K[6]=0.002216;for(int L=-6;L<=6;L++){float M=K[abs(L)];vec2 N=vec2(float(L)*Ud*H.x,0.);vec2 O=vec2(0.,float(L)*Ud*H.y);vec3 P=texture(u_texture,v_uv+N).rgb;I+=C(P,Uj)*M;if(L!=0){vec3 Q=texture(u_texture,v_uv+O).rgb;I+=C(Q,Uj)*M;J+=M;}J+=M;}float R=0.1;for(int L=1;L<=4;L++){float S=float(L)*Ud;vec2 T=vec2(S,S)*H;vec2 U=vec2(S,-S)*H;vec3 V=texture(u_texture,v_uv+T).rgb;vec3 W=texture(u_texture,v_uv-T).rgb;vec3 X=texture(u_texture,v_uv+U).rgb;vec3 Y=texture(u_texture,v_uv-U).rgb;float Z=R/float(L);I+=C(V,Uj)*Z;I+=C(W,Uj)*Z;I+=C(X,Uj)*Z;I+=C(Y,Uj)*Z;J+=Z*4.;}I/=J;vec3 a=G.rgb+I*Ua;fragColor=vec4(a,G.a);}",primary:"threshold",uniforms:{Uj:["threshold",.5],Ua:["intensity",1],Ud:["radius",4]}}),x=r({id:"crtMattias",shader:"#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float Uk;uniform float U3;uniform float Uf;in vec2 v_uv;out vec4 fragColor;vec3 A(vec2 B){vec3 C=pow(texture(u_texture,B).rgb,vec3(2.2));return C;}vec3 D(vec2 B,float E){vec4 F=E*vec4(-2.,-1.,1.,2.)/u_resolution.x;vec4 G=E*vec4(-2.,-1.,1.,2.)/u_resolution.y;vec3 H=vec3(0.);H+=A(B+vec2(F.x,G.x))*0.00366;H+=A(B+vec2(F.y,G.x))*0.01465;H+=A(B+vec2(0.,G.x))*0.02564;H+=A(B+vec2(F.z,G.x))*0.01465;H+=A(B+vec2(F.w,G.x))*0.00366;H+=A(B+vec2(F.x,G.y))*0.01465;H+=A(B+vec2(F.y,G.y))*0.05861;H+=A(B+vec2(0.,G.y))*0.09524;H+=A(B+vec2(F.z,G.y))*0.05861;H+=A(B+vec2(F.w,G.y))*0.01465;H+=A(B+vec2(F.x,0.))*0.02564;H+=A(B+vec2(F.y,0.))*0.09524;H+=A(B+vec2(0.,0.))*0.15018;H+=A(B+vec2(F.z,0.))*0.09524;H+=A(B+vec2(F.w,0.))*0.02564;H+=A(B+vec2(F.x,G.z))*0.01465;H+=A(B+vec2(F.y,G.z))*0.05861;H+=A(B+vec2(0.,G.z))*0.09524;H+=A(B+vec2(F.z,G.z))*0.05861;H+=A(B+vec2(F.w,G.z))*0.01465;H+=A(B+vec2(F.x,G.w))*0.00366;H+=A(B+vec2(F.y,G.w))*0.01465;H+=A(B+vec2(0.,G.w))*0.02564;H+=A(B+vec2(F.z,G.w))*0.01465;H+=A(B+vec2(F.w,G.w))*0.00366;return H;}float I(vec2 J){float K=12.9898;float L=78.233;float M=43758.5453;float N=dot(J.xy,vec2(K,L));float O=mod(N,3.14);return fract(sin(O)*M);}vec2 P(vec2 Q){Q=(Q-0.5)*2.;Q*=1.1;Q.x*=1.+pow((abs(Q.y)/5.),2.);Q.y*=1.+pow((abs(Q.x)/4.),2.);Q=(Q/2.)+0.5;Q=Q*0.92+0.04;return Q;}void main(){vec2 R=gl_FragCoord.xy;vec2 S=v_uv;vec2 Q=S;Q=mix(Q,P(Q),U3);vec3 T;float U=sin(0.1*Uk+Q.y*21.)*sin(0.23*Uk+Q.y*29.)*sin(0.3+0.11*Uk+Q.y*31.)*0.0017;float V=2.*mod(R.y,2.)/u_resolution.x;U+=V;T.r=1.*D(vec2(Q.x+0.0009,Q.y+0.0009),1.2).x+0.005;T.g=1.*D(vec2(Q.x+0.000,Q.y-0.0015),1.2).y+0.005;T.b=1.*D(vec2(Q.x-0.0015,Q.y+0.000),1.2).z+0.005;T.r+=0.2*D(vec2(Q.x+0.0009,Q.y+0.0009),2.25).x-0.005;T.g+=0.2*D(vec2(Q.x+0.000,Q.y-0.0015),1.75).y-0.005;T.b+=0.2*D(vec2(Q.x-0.0015,Q.y+0.000),1.25).z-0.005;float W=0.05;T.r+=W*(1.-0.299)*D(0.75*vec2(0.01,-0.027)+vec2(Q.x+0.001,Q.y+0.001),7.).x;T.g+=W*(1.-0.587)*D(0.75*vec2(-0.022,-0.02)+vec2(Q.x+0.000,Q.y-0.002),5.).y;T.b+=W*(1.-0.114)*D(0.75*vec2(-0.02,-0.)+vec2(Q.x-0.002,Q.y+0.000),3.).z;T=clamp(T*0.4+0.6*T*T*1.,0.,1.);float X=(0.+1.*16.*Q.x*Q.y*(1.-Q.x)*(1.-Q.y));X=pow(X,0.3);T*=vec3(X);T*=vec3(0.95,1.05,0.95);T=mix(T,T*T,0.3)*3.8;float Y=clamp(0.35+0.15*sin(3.5*(Uk*Uf)+Q.y*u_resolution.y*1.5),0.,1.);float C=pow(Y,0.9);T=T*vec3(C);T*=1.+0.0015*sin(300.*Uk);T*=1.-0.15*vec3(clamp((mod(R.x+V,2.)-1.)*2.,0.,1.));T*=vec3(1.)-0.25*vec3(I(Q+0.0001*Uk),I(Q+0.0001*Uk+0.3),I(Q+0.0001*Uk+0.5));T=pow(T,vec3(0.45));if(Q.x<0.||Q.x>1.)T*=0.;if(Q.y<0.||Q.y>1.)T*=0.;fragColor=vec4(T,1.);}",primary:"curvature",uniforms:{U3:["curvature",.5],Uf:["scanSpeed",1],Uk:["time",0]}}),_=r({id:"filmGrain",shader:"#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float Ua;uniform float Ug;uniform float Ui;uniform float Uk;in vec2 v_uv;out vec4 fragColor;float A(vec2 B){return fract(sin(dot(B,vec2(12.9898,78.233)))*43758.5453);}float C(vec2 D){vec2 E=floor(D);vec2 F=fract(D);vec2 G=F*F*(3.-2.*F);float H=A(E);float I=A(E+vec2(1.,0.));float J=A(E+vec2(0.,1.));float K=A(E+vec2(1.,1.));return mix(mix(H,I,G.x),mix(J,K,G.x),G.y);}void main(){vec4 L=texture(u_texture,v_uv);vec2 M=v_uv*u_resolution/Ug;M+=vec2(Uk*Ui*0.1);float N=C(M);float O=C(M*2.+vec2(100.));float P=C(M*4.+vec2(200.));float Q=N*0.6+O*0.3+P*0.1;Q=(Q-0.5)*Ua;float R=dot(L.rgb,vec3(0.299,0.587,0.114));float S=Q*(0.5+R*0.5);vec3 T=L.rgb+S;fragColor=vec4(T,L.a);}",primary:"intensity",uniforms:{Ua:["intensity",.2],Ug:["size",2],Ui:["speed",1],Uk:["time",0]}}),g=r({id:"glitch",shader:"#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float U0;in vec2 v_uv;out vec4 fragColor;float A(vec2 B){return fract(sin(dot(B.xy,vec2(12.9898,78.233)))*43758.5453);}void main(){vec2 C=v_uv;float D=U0*0.1;float E=floor(C.y*20.);float F=A(vec2(E,floor(U0*100.)));if(F>0.7){C.x+=(F-0.7)*D*2.;}float G=D*0.02;vec2 H=C+vec2(G,0.);vec2 I=C;vec2 J=C-vec2(G,0.);float K=texture(u_texture,H).r;float L=texture(u_texture,I).g;float M=texture(u_texture,J).b;float N=texture(u_texture,C).a;vec3 O=vec3(K,L,M);float P=sin(C.y*u_resolution.y*2.)*0.1*U0;O-=P;float Q=A(C+fract(U0))*0.1*U0;O+=Q;fragColor=vec4(O,N);}",primary:"amount",uniforms:{U0:["amount",0]}}),y=r({id:"scanlines",shader:"#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform float Uk;uniform float U2;uniform float Ua;uniform float Ui;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);float B=sin((v_uv.y*U2-Uk*Ui)*3.141592*2.);B=B*0.5+0.5;float C=1.-(Ua*(1.-B));fragColor=vec4(A.rgb*C,A.a);}",primary:"count",uniforms:{U2:["count",300],Ua:["intensity",.75],Ui:["speed",1],Uk:["time",0]}}),U=r({id:"vignette",shader:"#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float U0;uniform float Uh;uniform float Ue;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);vec2 B=v_uv*2.-1.;float C=u_resolution.x/u_resolution.y;B.x*=C;float D=max(abs(B.x),abs(B.y));float E=length(B);float F=mix(D,E,Ue);float G=mix(max(C,1.),length(vec2(C,1.)),Ue);F/=G;float H=1.-U0;float I=H+Uh*0.5+0.01;float J=1.-smoothstep(H,I,F);vec3 K=A.rgb*J;fragColor=vec4(K,A.a);}",primary:"amount",uniforms:{U0:["amount",.5],Uh:["softness",.5],Ue:["roundness",.5]}}),C=Object.freeze({invert:n,grayscale:a,sepia:v,threshold:l,brightness:o,contrast:i,saturation:f,hueRotate:s,posterize:u,chromaticAberration:c,pixelate:d,gridDistortion:m,glitch:g,crtMattias:x,scanlines:y,vignette:U,bloom:p,filmGrain:_}),F=class{t;o;i=new Map;u=!1;constructor(e,t,r){this.t=e,this.o=t;for(const o of r)this.i.set(o.id,{id:o.id,source:o.source,uniforms:o.uniforms,...o.primary?{primary:o.primary}:{}})}has(e){return this.i.has(e)}get(e){return this.i.get(e)}async register(e,t,r){const o="string"==typeof t?await this.t.createShader(this.o,t):t;this.u&&("string"==typeof t&&o.dispose(),this.v());const i=(a=r,Object.entries(a).map(([e,[t,r]])=>[e,t,r]));var a;this.l(e,{id:e,shader:o,uniforms:i,...i[0]?{primary:i[0][1]}:{}})}unregister(e){const t=this.i.get(e);return!!t&&(t.shader?.dispose(),this.i.delete(e),!0)}async initializeBuiltins(){const e=[];try{for(const[t,r]of this.i){if(!r.source||r.shader)continue;const o=await this.t.createShader(this.o,r.source);this.u&&(o.dispose(),this.v()),this.i.get(t)===r?(r.shader=o,e.push({descriptor:r,shader:o})):o.dispose()}}catch(t){for(const r of e.reverse())r.descriptor.shader===r.shader&&(r.descriptor.shader=void 0,this.u||r.shader.dispose());throw t}}dispose(){for(const e of this.i.values())e.shader?.dispose();this.i.clear(),this.u=!0}l(e,t){this.i.get(e)?.shader?.dispose(),this.i.set(e,t)}v(){if(this.u)throw new Error("TextmodeFilterManager has been disposed.")}},A=class{t;o;h=new WeakMap;m=new Set;p;constructor(e){this.t=e,this.o="#version 300 es\nlayout(location=0)in vec2 a_position;layout(location=1)in vec2 a_texCoord;out vec2 v_uv;void main(){v_uv=a_texCoord;gl_Position=vec4(a_position*2.,0.,1.);}"}get vertexSource(){return this.o}applyLayer(e,t,r){let o=this.h.get(e);return o||(o=this._(t.width,t.height),this.h.set(e,o)),this.U(t,r,o)}applyComposite(e,t){return this.p??=this._(e.width,e.height),this.U(e,t,this.p)}disposeLayer(e){const t=this.h.get(e);t&&this.C(t),this.h.delete(e)}dispose(){for(const e of[...this.m])this.C(e);this.h=new WeakMap,this.p=void 0}U(e,t,r){if(0===t.length)return e;this.F(r,e.width,e.height);let o=e;for(const i of t){const e=r[0]===o?r[1]:(r[1],r[0]);this.A(o,e,i.shader,this.B(i)),o=e}return o}A(e,t,r,o){this.t.push();let i=!1;try{t.begin(),i=!0,this.t.shader(r),this.t.setUniforms({u_texture:e.textures[0],u_resolution:[t.width,t.height],...o}),this.t.rect(t.width,t.height)}finally{try{i&&t.end()}finally{this.t.pop()}}}B(e){const t={};for(const[r,o,i]of e.uniforms){let a=i;if("number"==typeof e.params&&o===e.primary)a=e.params;else if(e.params&&"object"==typeof e.params&&o in e.params){const t=e.params[o];B(t)&&(a=t)}t[r]=a}return t}_(e,t){const r=[this.t.createFramebuffer({width:e,height:t,attachments:1,depth:!1}),this.t.createFramebuffer({width:e,height:t,attachments:1,depth:!1})];return this.m.add(r),r}F(e,t,r){e[0].width===t&&e[0].height===r||(e[0].resize(t,r),e[1].resize(t,r))}C(e){e[0].dispose(),e[1].dispose(),this.m.delete(e),this.p===e&&(this.p=void 0)}};function B(e){return"number"==typeof e||"boolean"==typeof e||Array.isArray(e)||e instanceof Float32Array||e instanceof Int32Array||"object"==typeof e&&null!==e}var D=class{D=0;H=!1;G=!1;J=[];T=[];L=new WeakMap;I=new Set;beginFrame(){this.D+=1;for(const e of this.I){const t=this.L.get(e);t&&(t.phase="draw")}this.H=!0}endFrame(){this.H=!1}queueLayer(e,t,r){const o=this.M(e);("postDraw"===o.phase?o.postQueue:o.drawQueue).push({name:t,params:r,frameToken:this.K()})}queueComposite(e,t){(this.G?this.T:this.J).push({name:e,params:t,frameToken:this.K()})}drainLayerDraw(e){return this.k(this.M(e).drawQueue)}drainLayerPostDraw(e){return this.k(this.M(e).postQueue)}setLayerPhase(e,t){this.M(e).phase=t}drainGlobal(){return this.k(this.J)}beginFinalDraw(){this.G=!0}endFinalDraw(){this.G=!1}drainFinal(){return this.k(this.T)}resetComposite(){this.J=[],this.T=[],this.G=!1}disposeLayer(e){this.L.delete(e),this.I.delete(e)}dispose(){this.J=[],this.T=[],this.L=new WeakMap,this.I.clear(),this.H=!1,this.G=!1}k(e){const t=this.D,r=[],o=[];for(const i of e)i.frameToken===t?r.push(i):i.frameToken>t&&o.push(i);return e.length=0,e.push(...o),r}M(e){let t=this.L.get(e);return t||(t={phase:"draw",drawQueue:[],postQueue:[]},this.L.set(e,t),this.I.add(e)),t}K(){return this.H?this.D:this.D+1}},b=class{t;O;P;S;N=()=>{};u=!1;constructor(e){this.t=e,this.S=new A(e),this.O=new F(e,this.S.vertexSource,Object.values(C)),this.P=new D}async register(e,t,r={}){if(this.v(),!e.trim())throw new TypeError("Filter id cannot be empty.");await this.O.register(e,t,r)}unregister(e){return this.O.unregister(e)}has(e){return this.O.has(e)}initializeBuiltins(){return this.v(),this.O.initializeBuiltins()}queueLayer(e,t,r){this.v(),this.P.queueLayer(e,t,r)}queueComposite(e,t){this.v(),this.P.queueComposite(e,t)}beginFrame(){this.P.beginFrame()}endFrame(){this.P.endFrame()}setFinalDrawCallback(e){this.N=e}transformLayer(e,t,r){if("resolved"===t){const t=this.j(r,this.P.drainLayerDraw(e),e,!1);return this.P.setLayerPhase(e,"postDraw"),t}try{return this.j(r,this.P.drainLayerPostDraw(e),e,!1)}finally{this.P.setLayerPhase(e,"draw")}}transformComposite(e){let t=e;try{t=this.j(t,this.P.drainGlobal(),void 0,!0),this.P.beginFinalDraw();try{this.N.call(this.t)}finally{this.P.endFinalDraw()}return this.j(t,this.P.drainFinal(),void 0,!0)}finally{this.P.resetComposite()}}disposeLayer(e){this.S.disposeLayer(e),this.P.disposeLayer(e)}dispose(){this.u||(this.O.dispose(),this.S.dispose(),this.P.dispose(),this.u=!0)}j(e,t,r,o){if(0===t.length)return e;const i=[];for(const a of t){const e=this.O.get(a.name);e?i.push(this.R(a.name,e,a.params)):console.warn(`[textmode.filters.js] Unknown filter: "${a.name}". Skipping.`)}return 0===i.length?e:o?this.S.applyComposite(e,i):this.S.applyLayer(r,e,i)}R(e,t,r){return{name:e,shader:this.W(t),uniforms:t.uniforms,params:r,...t.primary?{primary:t.primary}:{}}}W(e){if(e.shader)return e.shader;throw new Error("Filter shaders are not initialized. Wait for textmode setup to finish before drawing.")}v(){if(this.u)throw new Error("TextmodeFilterManager has been disposed.")}},w=new WeakMap,Q={name:"textmode.filters",version:"1.2.4-beta.1",install(e,t){const r=w.get(e);r&&r.dispose();const o=new b(e);w.set(e,o),function(e,t){e.on("preSetup",()=>t.initializeBuiltins()),e.defineExtension("textmodifier","filter",{value:(e,r)=>t.queueComposite(e,r)}),e.defineExtension("textmodifier","filters",{get:()=>t}),e.defineExtension("textmodifier","finalDraw",{value:e=>{t.setFinalDrawCallback(e)}}),e.defineExtension("layerManager","filters",{get:()=>t});const r=t.queueLayer.bind(t);e.defineExtension("layer","filter",{value(e,t){r(this,e,t)}}),e.on("layerDisposed",e=>t.disposeLayer(e)),e.on("layerOutput",({layer:e,phase:r,output:o})=>t.transformLayer(e,r,o)),e.on("compositeOutput",e=>t.transformComposite(e)),e.on("preDraw",()=>t.beginFrame()),e.on("postDraw",()=>t.endFrame())}(t,o)},uninstall(e){w.get(e)?.dispose(),w.delete(e)}};"undefined"!=typeof window&&(window.FiltersPlugin=Q),e.FiltersPlugin=Q,e.TextmodeFilterManager=b});
@@ -0,0 +1,163 @@
1
+ import type { BuiltinFilterDescriptor } from './definition';
2
+ import { type BrightnessOptions } from './color-adjustment/brightness';
3
+ import { type ContrastOptions } from './color-adjustment/contrast';
4
+ import { type GrayscaleOptions } from './color-adjustment/grayscale';
5
+ import { type HueRotateOptions } from './color-adjustment/hueRotate';
6
+ import { type PosterizeOptions } from './color-adjustment/posterize';
7
+ import { type SaturationOptions } from './color-adjustment/saturation';
8
+ import { type SepiaOptions } from './color-adjustment/sepia';
9
+ import { type ThresholdOptions } from './color-adjustment/threshold';
10
+ import { type ChromaticAberrationOptions } from './distortion/chromaticAberration';
11
+ import { type GridDistortionOptions } from './distortion/gridDistortion';
12
+ import { type PixelateOptions } from './distortion/pixelate';
13
+ import { type BloomOptions } from './stylization/bloom';
14
+ import { type CrtMattiasOptions } from './stylization/crtMattias';
15
+ import { type FilmGrainOptions } from './stylization/filmGrain';
16
+ import { type GlitchOptions } from './stylization/glitch';
17
+ import { type ScanlinesOptions } from './stylization/scanlines';
18
+ import { type VignetteOptions } from './stylization/vignette';
19
+ /**
20
+ * Parameter types for every built-in filter.
21
+ *
22
+ * @see {@link https://code.textmode.art/api/textmode.filters.js/interfaces/BuiltInFilterParameterMap | BuiltInFilterParameterMap API reference}
23
+ */
24
+ export interface BuiltInFilterParameterMap {
25
+ /**
26
+ * Invert has no configurable parameters.
27
+ *
28
+ * @see {@link https://code.textmode.art/api/textmode.filters.js/interfaces/BuiltInFilterParameterMap#property-invert | BuiltInFilterParameterMap.invert API reference}
29
+ */
30
+ invert: void;
31
+ /**
32
+ * Grayscale parameters.
33
+ *
34
+ * @see {@link https://code.textmode.art/api/textmode.filters.js/interfaces/BuiltInFilterParameterMap#property-grayscale | BuiltInFilterParameterMap.grayscale API reference}
35
+ */
36
+ grayscale: number | GrayscaleOptions | void;
37
+ /**
38
+ * Sepia parameters.
39
+ *
40
+ * @see {@link https://code.textmode.art/api/textmode.filters.js/interfaces/BuiltInFilterParameterMap#property-sepia | BuiltInFilterParameterMap.sepia API reference}
41
+ */
42
+ sepia: number | SepiaOptions | void;
43
+ /**
44
+ * Threshold parameters.
45
+ *
46
+ * @see {@link https://code.textmode.art/api/textmode.filters.js/interfaces/BuiltInFilterParameterMap#property-threshold | BuiltInFilterParameterMap.threshold API reference}
47
+ */
48
+ threshold: number | ThresholdOptions | void;
49
+ /**
50
+ * Brightness parameters.
51
+ *
52
+ * @see {@link https://code.textmode.art/api/textmode.filters.js/interfaces/BuiltInFilterParameterMap#property-brightness | BuiltInFilterParameterMap.brightness API reference}
53
+ */
54
+ brightness: number | BrightnessOptions | void;
55
+ /**
56
+ * Contrast parameters.
57
+ *
58
+ * @see {@link https://code.textmode.art/api/textmode.filters.js/interfaces/BuiltInFilterParameterMap#property-contrast | BuiltInFilterParameterMap.contrast API reference}
59
+ */
60
+ contrast: number | ContrastOptions | void;
61
+ /**
62
+ * Saturation parameters.
63
+ *
64
+ * @see {@link https://code.textmode.art/api/textmode.filters.js/interfaces/BuiltInFilterParameterMap#property-saturation | BuiltInFilterParameterMap.saturation API reference}
65
+ */
66
+ saturation: number | SaturationOptions | void;
67
+ /**
68
+ * Hue rotation parameters.
69
+ *
70
+ * @see {@link https://code.textmode.art/api/textmode.filters.js/interfaces/BuiltInFilterParameterMap#property-huerotate | BuiltInFilterParameterMap.hueRotate API reference}
71
+ */
72
+ hueRotate: number | HueRotateOptions | void;
73
+ /**
74
+ * Posterize parameters.
75
+ *
76
+ * @see {@link https://code.textmode.art/api/textmode.filters.js/interfaces/BuiltInFilterParameterMap#property-posterize | BuiltInFilterParameterMap.posterize API reference}
77
+ */
78
+ posterize: number | PosterizeOptions | void;
79
+ /**
80
+ * Chromatic aberration parameters.
81
+ *
82
+ * @see {@link https://code.textmode.art/api/textmode.filters.js/interfaces/BuiltInFilterParameterMap#property-chromaticaberration | BuiltInFilterParameterMap.chromaticAberration API reference}
83
+ */
84
+ chromaticAberration: number | ChromaticAberrationOptions | void;
85
+ /**
86
+ * Pixelate parameters.
87
+ *
88
+ * @see {@link https://code.textmode.art/api/textmode.filters.js/interfaces/BuiltInFilterParameterMap#property-pixelate | BuiltInFilterParameterMap.pixelate API reference}
89
+ */
90
+ pixelate: number | PixelateOptions | void;
91
+ /**
92
+ * Grid distortion parameters.
93
+ *
94
+ * @see {@link https://code.textmode.art/api/textmode.filters.js/interfaces/BuiltInFilterParameterMap#property-griddistortion | BuiltInFilterParameterMap.gridDistortion API reference}
95
+ */
96
+ gridDistortion: number | GridDistortionOptions | void;
97
+ /**
98
+ * Glitch parameters.
99
+ *
100
+ * @see {@link https://code.textmode.art/api/textmode.filters.js/interfaces/BuiltInFilterParameterMap#property-glitch | BuiltInFilterParameterMap.glitch API reference}
101
+ */
102
+ glitch: number | GlitchOptions | void;
103
+ /**
104
+ * CRT simulation parameters.
105
+ *
106
+ * @see {@link https://code.textmode.art/api/textmode.filters.js/interfaces/BuiltInFilterParameterMap#property-crtmattias | BuiltInFilterParameterMap.crtMattias API reference}
107
+ */
108
+ crtMattias: number | CrtMattiasOptions | void;
109
+ /**
110
+ * Scanline parameters.
111
+ *
112
+ * @see {@link https://code.textmode.art/api/textmode.filters.js/interfaces/BuiltInFilterParameterMap#property-scanlines | BuiltInFilterParameterMap.scanlines API reference}
113
+ */
114
+ scanlines: number | ScanlinesOptions | void;
115
+ /**
116
+ * Vignette parameters.
117
+ *
118
+ * @see {@link https://code.textmode.art/api/textmode.filters.js/interfaces/BuiltInFilterParameterMap#property-vignette | BuiltInFilterParameterMap.vignette API reference}
119
+ */
120
+ vignette: number | VignetteOptions | void;
121
+ /**
122
+ * Bloom parameters.
123
+ *
124
+ * @see {@link https://code.textmode.art/api/textmode.filters.js/interfaces/BuiltInFilterParameterMap#property-bloom | BuiltInFilterParameterMap.bloom API reference}
125
+ */
126
+ bloom: number | BloomOptions | void;
127
+ /**
128
+ * Film grain parameters.
129
+ *
130
+ * @see {@link https://code.textmode.art/api/textmode.filters.js/interfaces/BuiltInFilterParameterMap#property-filmgrain | BuiltInFilterParameterMap.filmGrain API reference}
131
+ */
132
+ filmGrain: number | FilmGrainOptions | void;
133
+ }
134
+ /**
135
+ * Names installed synchronously by {@link FiltersPlugin}.
136
+ *
137
+ * @see {@link https://code.textmode.art/api/textmode.filters.js/type-aliases/BuiltInFilterName | BuiltInFilterName API reference}
138
+ */
139
+ export type BuiltInFilterName = keyof BuiltInFilterParameterMap;
140
+ /**
141
+ * The authoritative shipped set of built-in filters. Its keys are compile-time checked to match
142
+ * {@link BuiltInFilterParameterMap} exactly. Internal to the runtime; never exported from the package root.
143
+ */
144
+ export declare const BUILTIN_CATALOG: Readonly<{
145
+ invert: BuiltinFilterDescriptor;
146
+ grayscale: BuiltinFilterDescriptor;
147
+ sepia: BuiltinFilterDescriptor;
148
+ threshold: BuiltinFilterDescriptor;
149
+ brightness: BuiltinFilterDescriptor;
150
+ contrast: BuiltinFilterDescriptor;
151
+ saturation: BuiltinFilterDescriptor;
152
+ hueRotate: BuiltinFilterDescriptor;
153
+ posterize: BuiltinFilterDescriptor;
154
+ chromaticAberration: BuiltinFilterDescriptor;
155
+ pixelate: BuiltinFilterDescriptor;
156
+ gridDistortion: BuiltinFilterDescriptor;
157
+ glitch: BuiltinFilterDescriptor;
158
+ crtMattias: BuiltinFilterDescriptor;
159
+ scanlines: BuiltinFilterDescriptor;
160
+ vignette: BuiltinFilterDescriptor;
161
+ bloom: BuiltinFilterDescriptor;
162
+ filmGrain: BuiltinFilterDescriptor;
163
+ }>;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Configuration options for the `'brightness'` filter.
3
+ *
4
+ * Adjusts image brightness by multiplying pixel values.
5
+ *
6
+ * @example
7
+ * {@includeCode ../../../examples/ColorAdjustment/brightness/sketch.js}
8
+ *
9
+ * @category Color adjustment filters
10
+ *
11
+ * @see {@link https://code.textmode.art/api/textmode.filters.js/interfaces/BrightnessOptions | BrightnessOptions API reference}
12
+ */
13
+ export interface BrightnessOptions {
14
+ /**
15
+ * Brightness multiplier.
16
+ *
17
+ * - `1.0` = normal brightness (no change)
18
+ * - `> 1.0` = brighter
19
+ * - `< 1.0` = darker
20
+ * - `0.0` = completely black
21
+ *
22
+ * @default 1.0
23
+ *
24
+ * @see {@link https://code.textmode.art/api/textmode.filters.js/interfaces/BrightnessOptions#amount | BrightnessOptions.amount API reference}
25
+ */
26
+ amount?: number;
27
+ }
28
+ export declare const brightnessFilter: import("../definition").BuiltinFilterDescriptor;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Configuration options for the `'contrast'` filter.
3
+ *
4
+ * Adjusts image contrast by scaling pixel values around mid-gray.
5
+ *
6
+ * @example
7
+ * {@includeCode ../../../examples/ColorAdjustment/contrast/sketch.js}
8
+ *
9
+ * @category Color adjustment filters
10
+ *
11
+ * @see {@link https://code.textmode.art/api/textmode.filters.js/interfaces/ContrastOptions | ContrastOptions API reference}
12
+ */
13
+ export interface ContrastOptions {
14
+ /**
15
+ * Contrast multiplier.
16
+ *
17
+ * - `1.0` = normal contrast (no change)
18
+ * - `> 1.0` = more contrast (darker darks, brighter brights)
19
+ * - `< 1.0` = less contrast (more gray/washed out)
20
+ * - `0.0` = solid gray
21
+ *
22
+ * @default 1.0
23
+ *
24
+ * @see {@link https://code.textmode.art/api/textmode.filters.js/interfaces/ContrastOptions#amount | ContrastOptions.amount API reference}
25
+ */
26
+ amount?: number;
27
+ }
28
+ export declare const contrastFilter: import("../definition").BuiltinFilterDescriptor;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Options for the built-in grayscale effect.
3
+ *
4
+ * @see {@link https://code.textmode.art/api/textmode.filters.js/interfaces/GrayscaleOptions | GrayscaleOptions API reference}
5
+ */
6
+ export interface GrayscaleOptions {
7
+ /**
8
+ * Grayscale blend amount, from `0` (original color) to `1` (fully grayscale).
9
+ *
10
+ * @see {@link https://code.textmode.art/api/textmode.filters.js/interfaces/GrayscaleOptions#property-amount | GrayscaleOptions.amount API reference}
11
+ */
12
+ amount?: number;
13
+ }
14
+ export declare const grayscaleFilter: import("../definition").BuiltinFilterDescriptor;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Configuration options for the `'hueRotate'` filter.
3
+ *
4
+ * Shifts all colors around the color wheel by a specified angle.
5
+ * Useful for color grading or creating surreal color effects.
6
+ *
7
+ * @example
8
+ * {@includeCode ../../../examples/ColorAdjustment/hueRotate/sketch.js}
9
+ *
10
+ * @category Color adjustment filters
11
+ *
12
+ * @see {@link https://code.textmode.art/api/textmode.filters.js/interfaces/HueRotateOptions | HueRotateOptions API reference}
13
+ */
14
+ export interface HueRotateOptions {
15
+ /**
16
+ * Rotation angle in degrees.
17
+ *
18
+ * - `0` = no change
19
+ * - `180` = complementary colors
20
+ * - `360` = full rotation (same as 0)
21
+ *
22
+ * Values wrap around, so `370` is equivalent to `10`.
23
+ *
24
+ * @default 0.0
25
+ *
26
+ * @see {@link https://code.textmode.art/api/textmode.filters.js/interfaces/HueRotateOptions#angle | HueRotateOptions.angle API reference}
27
+ */
28
+ angle?: number;
29
+ }
30
+ export declare const hueRotateFilter: import("../definition").BuiltinFilterDescriptor;
@@ -0,0 +1 @@
1
+ export declare const invertFilter: import("../definition").BuiltinFilterDescriptor;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Configuration options for the `'posterize'` filter.
3
+ *
4
+ * Reduces the color palette to a limited number of bands per channel,
5
+ * creating a retro quantized/poster-like look.
6
+ *
7
+ * @example
8
+ * {@includeCode ../../../examples/ColorAdjustment/posterize/sketch.js}
9
+ *
10
+ * @category Color adjustment filters
11
+ *
12
+ * @see {@link https://code.textmode.art/api/textmode.filters.js/interfaces/PosterizeOptions | PosterizeOptions API reference}
13
+ */
14
+ export interface PosterizeOptions {
15
+ /**
16
+ * Number of color levels per channel.
17
+ *
18
+ * Lower values create more dramatic banding effects.
19
+ * Higher values approach the original image quality.
20
+ *
21
+ * - `2` = extreme posterization (very few colors)
22
+ * - `4` = strong posterization (default)
23
+ * - `8+` = subtle posterization
24
+ *
25
+ * @default 4.0
26
+ *
27
+ * @see {@link https://code.textmode.art/api/textmode.filters.js/interfaces/PosterizeOptions#levels | PosterizeOptions.levels API reference}
28
+ */
29
+ levels?: number;
30
+ }
31
+ export declare const posterizeFilter: import("../definition").BuiltinFilterDescriptor;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Configuration options for the `'saturation'` filter.
3
+ *
4
+ * Adjusts color intensity without affecting luminance.
5
+ * Perfect for creating vivid, oversaturated looks or desaturating to grayscale.
6
+ *
7
+ * @example
8
+ * {@includeCode ../../../examples/ColorAdjustment/saturation/sketch.js}
9
+ *
10
+ * @category Color adjustment filters
11
+ *
12
+ * @see {@link https://code.textmode.art/api/textmode.filters.js/interfaces/SaturationOptions | SaturationOptions API reference}
13
+ */
14
+ export interface SaturationOptions {
15
+ /**
16
+ * Saturation multiplier.
17
+ *
18
+ * - `0.0` = grayscale (no color)
19
+ * - `1.0` = normal saturation (no change)
20
+ * - `> 1.0` = vivid/oversaturated colors
21
+ *
22
+ * @default 1.0
23
+ *
24
+ * @see {@link https://code.textmode.art/api/textmode.filters.js/interfaces/SaturationOptions#amount | SaturationOptions.amount API reference}
25
+ */
26
+ amount?: number;
27
+ }
28
+ export declare const saturationFilter: import("../definition").BuiltinFilterDescriptor;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Options for the built-in sepia effect.
3
+ *
4
+ * @see {@link https://code.textmode.art/api/textmode.filters.js/interfaces/SepiaOptions | SepiaOptions API reference}
5
+ */
6
+ export interface SepiaOptions {
7
+ /**
8
+ * Sepia blend amount, from `0` (original color) to `1` (full sepia).
9
+ *
10
+ * @see {@link https://code.textmode.art/api/textmode.filters.js/interfaces/SepiaOptions#property-amount | SepiaOptions.amount API reference}
11
+ */
12
+ amount?: number;
13
+ }
14
+ export declare const sepiaFilter: import("../definition").BuiltinFilterDescriptor;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Options for the built-in threshold effect.
3
+ *
4
+ * @see {@link https://code.textmode.art/api/textmode.filters.js/interfaces/ThresholdOptions | ThresholdOptions API reference}
5
+ */
6
+ export interface ThresholdOptions {
7
+ /**
8
+ * Luminance cutoff used to choose black or white output.
9
+ *
10
+ * @see {@link https://code.textmode.art/api/textmode.filters.js/interfaces/ThresholdOptions#property-threshold | ThresholdOptions.threshold API reference}
11
+ */
12
+ threshold?: number;
13
+ }
14
+ export declare const thresholdFilter: import("../definition").BuiltinFilterDescriptor;
@@ -0,0 +1,26 @@
1
+ import type { TextmodeUniformValue } from 'textmode.js';
2
+ /**
3
+ * One normalized uniform binding for a built-in filter.
4
+ */
5
+ export type BuiltinUniformBinding = readonly [uniform: string, parameter: string, defaultValue: TextmodeUniformValue];
6
+ /**
7
+ * Runtime descriptor for one built-in filter, produced by {@link defineBuiltinFilter}.
8
+ */
9
+ export interface BuiltinFilterDescriptor {
10
+ readonly id: string;
11
+ readonly source: string;
12
+ readonly uniforms: readonly BuiltinUniformBinding[];
13
+ readonly primary?: string;
14
+ }
15
+ /**
16
+ * Define one built-in filter by co-locating its option type, fragment shader, and uniform mappings.
17
+ *
18
+ * The helper only builds an internal descriptor. It never compiles shaders, registers filters, or
19
+ * touches plugin lifecycle.
20
+ */
21
+ export declare function defineBuiltinFilter<TOptions extends object>(definition: {
22
+ readonly id: string;
23
+ readonly shader: string;
24
+ readonly uniforms: Readonly<Record<string, readonly [parameter: keyof TOptions, defaultValue: TextmodeUniformValue]>>;
25
+ readonly primary?: keyof TOptions;
26
+ }): BuiltinFilterDescriptor;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Configuration options for the `'chromaticAberration'` filter.
3
+ *
4
+ * RGB color channel separation effect that simulates lens distortion
5
+ * found in cheap cameras or creates stylized glitch aesthetics.
6
+ *
7
+ * @example
8
+ * {@includeCode ../../../examples/Distortion/chromaticAberration/sketch.js}
9
+ *
10
+ * @category Distortion filters
11
+ *
12
+ * @see {@link https://code.textmode.art/api/textmode.filters.js/interfaces/ChromaticAberrationOptions | ChromaticAberrationOptions API reference}
13
+ */
14
+ export interface ChromaticAberrationOptions {
15
+ /**
16
+ * Offset amount in pixels.
17
+ *
18
+ * Controls how far the red and blue channels are separated from green.
19
+ *
20
+ * @default 5.0
21
+ *
22
+ * @see {@link https://code.textmode.art/api/textmode.filters.js/interfaces/ChromaticAberrationOptions#amount | ChromaticAberrationOptions.amount API reference}
23
+ */
24
+ amount?: number;
25
+ /**
26
+ * Direction of the color separation as `[x, y]`.
27
+ *
28
+ * - `[1, 0]` = horizontal separation
29
+ * - `[0, 1]` = vertical separation
30
+ * - `[1, 1]` = diagonal separation
31
+ *
32
+ * The vector is normalized internally, so `[2, 0]` is the same as `[1, 0]`.
33
+ *
34
+ * @default [1.0, 0.0]
35
+ *
36
+ * @see {@link https://code.textmode.art/api/textmode.filters.js/interfaces/ChromaticAberrationOptions#direction | ChromaticAberrationOptions.direction API reference}
37
+ */
38
+ direction?: [number, number];
39
+ }
40
+ export declare const chromaticAberrationFilter: import("../definition").BuiltinFilterDescriptor;