Created
April 30, 2022 01:26
-
-
Save phunanon/0212b546abccc22cd06f5eb89a4cecad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(var W 80 H 25 | |
chars ".,-~:;=!*#$@" | |
PI2 (* 2 PI) | |
speed-A .05 speed-B .05 speed-I .05 speed-J .05 | |
a 0 b 0) | |
(var last-ms (time)) | |
(function calculate-screen screen | |
(let prev-ms last-ms) | |
(str | |
(- (var last-ms (time)) prev-ms) "ms between frames\n" | |
(join "\n" (map (.. str) (partition W screen))))) | |
(while true | |
(let grid (times (* H W) " ") | |
_grid (times (* H W) 0) | |
j 0) | |
(while (< j PI2) | |
(let j (+ j speed-I) i 0) | |
(while (< i PI2) | |
(let i (+ i speed-I) | |
[sa sb sc sd] (map sin [a b i j]) | |
[ca cb cc cd] (map cos [a b i j]) | |
cd+2 (+ cd 2) | |
e (/ 1 (+ (* sc cd+2 sa) (* sd ca) 5)) | |
f (- (* sc cd+2 ca) (* sd sa)) | |
x (floor (+ (/ W 2) (* 30 e (- (* cc cd+2 cb) (* f sb))))) | |
y (floor (+ (/ H 2) (* 15 e (+ (* cc cd+2 sb) (* f cb))))) | |
index (+ x (* W y))) | |
(when (and (< 0 y H) (< 0 x W) (< (index _grid) e)) | |
(let z (floor (* 8 (- (* (- (* sd sa) (* sc cd ca)) cb) | |
(* sc cd sa) | |
(* sd ca) | |
(* cc cd sb))))) | |
(var _grid (set-at [index] e _grid) | |
grid (set-at [index] ((max z 0) chars) grid))))) | |
(print (calculate-screen grid)) | |
(var a (+ a speed-A) b (+ b speed-B))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment