@kecan0406/ttheme 1.0.33 → 1.0.35

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.
@@ -1,141 +0,0 @@
1
- // ripple_cursor.glsl — from sahaj-b/ghostty-cursor-shaders (MIT).
2
- // https://github.com/sahaj-b/ghostty-cursor-shaders
3
- // See LICENSE in this directory. Local change: COLOR follows the theme cursor.
4
-
5
- // sRGB -> Linear conversion (needed because Ghostty passes sRGB values but the shader pipeline operates in linear color space)
6
- vec3 sRGBToLinear(vec3 c) {
7
- return mix(c / 12.92, pow((c + 0.055) / 1.055, vec3(2.4)), step(vec3(0.04045), c));
8
- }
9
-
10
- // CONFIGURATION
11
- const float DURATION = 0.15; // How long the ripple animates (seconds)
12
- const float MAX_RADIUS = 0.05; // Max radius in normalized coords (0.5 = 1/4 screen height)
13
- const float RING_THICKNESS = 0.02; // Ring width in normalized coords
14
- const float CURSOR_WIDTH_CHANGE_THRESHOLD = 0.5; // Triggers ripple if cursor width changes by this fraction
15
- vec4 COLOR = vec4(sRGBToLinear(iCurrentCursorColor.rgb), 1.0); // for custom color: vec4(0.35, 0.36, 0.44, 1.0)
16
- const float BLUR = 3.0; // Blur level in pixels
17
- const float ANIMATION_START_OFFSET = 0.0; // Start the ripple slightly progressed (0.0 - 1.0)
18
-
19
-
20
- // Easing functions
21
- float easeOutQuad(float t) {
22
- return 1.0 - (1.0 - t) * (1.0 - t);
23
- }
24
- float easeInOutQuad(float t) {
25
- return t < 0.5 ? 2.0 * t * t : 1.0 - pow(-2.0 * t + 2.0, 2.0) / 2.0;
26
- }
27
- float easeOutCubic(float t) {
28
- return 1.0 - pow(1.0 - t, 3.0);
29
- }
30
- float easeOutQuart(float t) {
31
- return 1.0 - pow(1.0 - t, 4.0);
32
- }
33
- float easeOutQuint(float t) {
34
- return 1.0 - pow(1.0 - t, 5.0);
35
- }
36
- float easeOutExpo(float t) {
37
- return t == 1.0 ? 1.0 : 1.0 - pow(2.0, -10.0 * t);
38
- }
39
- float easeOutCirc(float t) {
40
- return sqrt(1.0 - pow(t - 1.0, 2.0));
41
- }
42
- float easeOutSine(float t) {
43
- return sin((t * 3.1415916) / 2.0);
44
- }
45
- float easeOutElastic(float t) {
46
- const float c4 = (2.0 * 3.1415916) / 3.0;
47
- return t == 0.0 ? 0.0 : t == 1.0 ? 1.0 : pow(2.0, -10.0 * t) * sin((t * 10.0 - 0.75) * c4) + 1.0;
48
- }
49
- float easeOutBounce(float t) {
50
- const float n1 = 7.5625;
51
- const float d1 = 2.75;
52
- if (t < 1.0 / d1) {
53
- return n1 * t * t;
54
- } else if (t < 2.0 / d1) {
55
- return n1 * (t -= 1.5 / d1) * t + 0.75;
56
- } else if (t < 2.5 / d1) {
57
- return n1 * (t -= 2.25 / d1) * t + 0.9375;
58
- } else {
59
- return n1 * (t -= 2.625 / d1) * t + 0.984375;
60
- }
61
- }
62
- float easeOutBack(float t) {
63
- const float c1 = 1.70158;
64
- const float c3 = c1 + 1.0;
65
- return 1.0 + c3 * pow(t - 1.0, 3.0) + c1 * pow(t - 1.0, 2.0);
66
- }
67
-
68
- // Pulse fade functions
69
- float easeOutPulse(float t) {
70
- return t * (2.0 - t);
71
- }
72
- float exponentialDecayPulse(float t) {
73
- return exp(-3.0 * t) * sin(t * 3.1415916);
74
- }
75
-
76
- vec2 normalize(vec2 value, float isPosition) {
77
- return (value * 2.0 - (iResolution.xy * isPosition)) / iResolution.y;
78
- }
79
-
80
- void mainImage(out vec4 fragColor, in vec2 fragCoord){
81
- #if !defined(WEB)
82
- fragColor = texture(iChannel0, fragCoord.xy / iResolution.xy);
83
- #endif
84
-
85
- // Normalization & setup (-1 to 1 coords)
86
- vec2 vu = normalize(fragCoord, 1.);
87
- vec2 offsetFactor = vec2(-.5, 0.5);
88
-
89
- vec4 currentCursor = vec4(normalize(iCurrentCursor.xy, 1.), normalize(iCurrentCursor.zw, 0.));
90
- vec4 previousCursor = vec4(normalize(iPreviousCursor.xy, 1.), normalize(iPreviousCursor.zw, 0.));
91
-
92
- vec2 centerCC = currentCursor.xy - (currentCursor.zw * offsetFactor);
93
-
94
- float cellWidth = max(currentCursor.z, previousCursor.z); // width of the 'block' cursor
95
-
96
- // check for significant width change
97
- float widthChange = abs(currentCursor.z - previousCursor.z);
98
- float widthThresholdNorm = cellWidth * CURSOR_WIDTH_CHANGE_THRESHOLD;
99
- float isModeChange = step(widthThresholdNorm, widthChange);
100
-
101
-
102
- // ANIMATION
103
- float rippleProgress = (iTime - iTimeCursorChange) / DURATION + ANIMATION_START_OFFSET;
104
- // don't clamp yet; we need to know if it's > 1.0 (finished)
105
- float isAnimating = 1.0 - step(1.0, rippleProgress); // progress < 1.0 ? 1.0: 0.0
106
-
107
- if (isModeChange > 0.0 && isAnimating > 0.0) {
108
- // Apply easing to progress
109
- // float easedProgress = rippleProgress;
110
- // float easedProgress = easeOutQuad(rippleProgress);
111
- // float easedProgress = easeInOutQuad(rippleProgress);
112
- // float easedProgress = easeOutCubic(rippleProgress);
113
- // float easedProgress = easeOutQuart(rippleProgress);
114
- // float easedProgress = easeOutQuint(rippleProgress);
115
- // float easedProgress = easeOutExpo(rippleProgress);
116
- float easedProgress = easeOutCirc(rippleProgress);
117
- // float easedProgress = easeOutSine(rippleProgress);
118
- // float easedProgress = easeOutBack(rippleProgress);
119
-
120
- // RIPPLE CALCULATION
121
- float rippleRadius = easedProgress * MAX_RADIUS;
122
-
123
- // float fade = 1.0; // no fade
124
- // float fade = 1.0 - easedProgress; // linear fade
125
- float fade = 1.0 - easeOutPulse(rippleProgress);
126
- // float fade = 1.0 - exponentialDecayPulse(rippleProgress);
127
-
128
- // Calculate distance from frag to cursor center
129
- float dist = distance(vu, centerCC);
130
-
131
- float sdfRing = abs(dist - rippleRadius) - RING_THICKNESS * 0.5;
132
-
133
- // Antialias (1-pixel width in normalized coords)
134
- float antiAliasSize = normalize(vec2(BLUR, BLUR), 0.0).x;
135
- float ripple = (1.0 - smoothstep(-antiAliasSize, antiAliasSize, sdfRing)) * fade;
136
-
137
- // Apply ripple effect
138
- fragColor = mix(fragColor, COLOR, ripple * COLOR.a);
139
- }
140
- // else: do nothing, keep original fragColor
141
- }