gl-transitions 1.46.0 → 1.48.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gl-transitions",
3
- "version": "1.46.0",
3
+ "version": "1.48.0",
4
4
  "description": "The open collection of GL Transitions",
5
5
  "main": "index.js",
6
6
  "license": "MIT",
@@ -0,0 +1,29 @@
1
+ // Author: lql
2
+ // License: MIT
3
+ uniform int rectIn; // =1
4
+ // center:0, left_top:1, left_bottom:2, right_top:3, right_bottom:4
5
+ uniform int location; // =0
6
+
7
+ vec4 transition(vec2 uv) {
8
+ float p = rectIn == 1 ? 1.0 - progress : progress;
9
+ float x1, y1, x2, y2;
10
+
11
+ // Determine rectangle coordinates based on location
12
+ if (location == 0) {
13
+ x1 = y1 = 0.5 * (1.0 - p);
14
+ x2 = y2 = 1.0 - x1;
15
+ } else {
16
+ // Calculate the x and y coordinates based on the location
17
+ x1 = (location == 1 || location == 2) ? 0.0 : 1.0 - p;
18
+ y1 = (location == 1 || location == 3) ? 1.0 - p : 0.0;
19
+ x2 = (location == 1 || location == 2) ? p : 1.0;
20
+ y2 = (location == 1 || location == 3) ? 1.0 : p;
21
+ }
22
+
23
+ // Determine if the point is inside the rectangle
24
+ float in_rect = step(x1, uv.x) * step(uv.x, x2) * step(y1, uv.y) * step(uv.y, y2);
25
+ in_rect = rectIn == 1 ? 1.0 - in_rect : in_rect;
26
+
27
+ // Mix colors based on the in_rect value
28
+ return mix(getFromColor(uv), getToColor(uv), in_rect);
29
+ }
@@ -3,14 +3,16 @@
3
3
 
4
4
  // Custom parameters
5
5
  uniform float size; // = 0.2
6
+ uniform bool reversed; // = false;
6
7
 
7
8
  float rand (vec2 co) {
8
9
  return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
9
10
  }
10
11
 
11
12
  vec4 transition (vec2 uv) {
13
+ float x = reversed ? 1. - uv.x : uv.x;
12
14
  float r = rand(vec2(0, uv.y));
13
- float m = smoothstep(0.0, -size, uv.x*(1.0-size) + size*r - (progress * (1.0 + size)));
15
+ float m = smoothstep(0.0, -size, x*(1.0-size) + size*r - (progress * (1.0 + size)));
14
16
  return mix(
15
17
  getFromColor(uv),
16
18
  getToColor(uv),