Created
June 4, 2024 21:27
-
-
Save icavalheiro/7eae2ec73dc258bfad6fb2e97b6f4b21 to your computer and use it in GitHub Desktop.
Revisions
-
icavalheiro created this gist
Jun 4, 2024 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,65 @@ using System.Text; float sin(float x) { return MathF.Sin(x); } float cos(float x) { return MathF.Cos(x); } int k; float A = 0, B = 0, i, j; float[] z = new float[1760]; char[] b = new char[1760]; Console.WriteLine("\x1b[2J"); StringBuilder sb; for (; ; ) { Thread.Sleep((int)(1000 * (1/24f)));//force to run in 24 FPS sb = new(); Array.Fill(b, ' '); Array.Fill(z, 0.0f); for (j = 0; 6.28f > j; j += 0.07f) { for (i = 0; 6.28f > i; i += 0.02f) { float c = sin(i), d = cos(j), e = sin(A), f = sin(j), g = cos(A), h = d + 2, D = 1 / (c * h * e + f * g + 5), l = cos(i), m = cos(B), n = sin(B), t = c * h * g - f * e; int x = (int)(40 + 30 * D * (l * h * m - t * n)), y = (int)(12 + 15 * D * (l * h * n + t * m)), o = x + 80 * y, N = (int)(8 * ((f * e - c * d * g) * m - c * d * e - f * g - l * d * n)); if (22 > y && y > 0 && x > 0 && 80 > x && D > z[o]) { z[o] = D; b[o] = ".,-~:;=!*#$@"[N > 0 ? N : 0]; } } } sb.AppendLine("\x1b[H"); for (k = 0; k < 1761; k++) { if (k % 80 == 0 && k != 0) sb.AppendLine(""); else if (k < 1760) // Ensure we don't access out of bounds sb.Append(b[k]); } A += 0.04f; B += 0.02f; Console.Write(sb.ToString()); }