#!/usr/bin/gawk -f # reinhard@finalmedia.de # Thu May 14 11:06:17 AM CEST 2026 # Public Domain # Beispiel: gawk -v width=1920 -v height=1080 -f barnsley.awk > /dev/shm/videocmd BEGIN { # Validierung der übergebenen Dimensionen (Fallbacks falls nicht gesetzt) if (!width) width = 1920; if (!height) height = 1080; # Zufallsgenerator initialisieren srand(); # Startkoordinaten für das Fraktal x = 0.0; y = 0.0; # Variablen für die Oszillations-Wellen (Timing & Dichte) step_time = 0; step_density = 0; target_density = 500; count = 0; # Bildschirm initial leeren (schwarz übermalen) print "c 0 0 0"; print "m 0 0"; print "r " width " " height; # Endlosschleife zur Live-Generierung while (1) { # Zufallszahl zwischen 0 und 99 erzeugen r = int(rand() * 100); if (r < 1) { # Stamm (1%) next_x = 0.0; next_y = 0.16 * y; cr = 120; cg = 80; cb = 40; # Braun } else if (r < 86) { # Hauptblätter (85%) next_x = 0.85 * x + 0.04 * y; next_y = -0.04 * x + 0.85 * y + 1.6; cr = 34; cg = 139; cb = 34; # Waldgrün } else if (r < 93) { # Linke Seitenzweige (7%) next_x = 0.20 * x - 0.26 * y; next_y = 0.23 * x + 0.22 * y + 1.6; cr = 50; cg = 205; cb = 50; # Hellgrün } else { # Rechte Seitenzweige (7%) next_x = -0.15 * x + 0.28 * y; next_y = 0.26 * x + 0.24 * y + 0.44; cr = 0; cg = 250; cb = 154; # Neongrün } x = next_x; y = next_y; # Mathematische Koordinaten auf die Bildschirmauflösung skalieren screen_x = (x + 2.182) / 4.8388 * (width - 100) + 50; screen_y = (height - 50) - (y / 9.9983 * (height - 100)); # Runden auf Ganzzahl (Pixelkoordinaten) via int() + 0.5 ix = int(screen_x + 0.5); iy = int(screen_y + 0.5); # Prüfen, ob der Pixel im sichtbaren Bereich liegt if (ix >= 0 && ix < width && iy >= 0 && iy < height) { print "p " ix " " iy " " cr " " cg " " cb; count++; } # Dynamische Frame-Taktung (Injektion des s-Befehls) if (count >= target_density) { # Wartezeit oszilliert sinusförmig (4.000 bis 26.000 us) step_time += 0.04; sleep_time = int(15000 + 11000 * sin(step_time)); print "s " sleep_time; # Dichte für den nächsten Frame oszilliert (100 bis 1.100 Pixel) step_density += 0.07; target_density = int(600 + 500 * cos(step_density)); # Stream-Buffer sofort leeren, um Latenzen in der Pipe zu verhindern fflush(); count = 0; } } }