aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--toy-braids.vert24
1 files changed, 24 insertions, 0 deletions
diff --git a/toy-braids.vert b/toy-braids.vert
new file mode 100644
index 0000000..df7f2bf
--- /dev/null
+++ b/toy-braids.vert
@@ -0,0 +1,24 @@
+const float step = 0.02;
+const float mag = 0.3;
+const float size = 0.6;
+const float turns = 9.0;
+
+const float pi_2 = 6.28318530718;
+
+void mainImage(out vec4 fragColor, in vec2 fragCoord) {
+ vec2 norm = (fragCoord / iResolution.xy - 0.5) * 2.0;
+ float offset = iTime * 2.0;
+
+ fragColor = vec4(0.0, 0.0, 0.0, 1.0);
+ for (float t = 0.0; t < pi_2; t += step) {
+ // <https://www.desmos.com/calculator/e0kq6z1ndd>
+ vec2 f = vec2(
+ size * (cos(t) + mag * cos(turns * t + offset)),
+ size * (sin(t) + mag * sin(turns * t + offset))
+ );
+ if (length(f - norm) < 0.04) {
+ fragColor = vec4(1.0, 1.0, 1.0, 1.0);
+ }
+ }
+}
+