Skip to content

Instantly share code, notes, and snippets.

@BjoernSchilberg
Created March 5, 2025 20:56
Show Gist options
  • Save BjoernSchilberg/0c7a0e9dd6cd4c7559a9d9b74e108215 to your computer and use it in GitHub Desktop.
Save BjoernSchilberg/0c7a0e9dd6cd4c7559a9d9b74e108215 to your computer and use it in GitHub Desktop.
"Event Horizon" in one equation
// https://x.com/tsoding/status/1897049953090068614/photo/1
//cc -o main main.c -lm && ./main
#include <stdio.h>
#include <math.h>
#define WIDTH 30
#define HEIGHT 30
int main() {
float w = WIDTH;
float h = HEIGHT;
for (int col=0; col < HEIGHT; ++col){
for (int row=0; row < WIDTH; ++row) {
float x = col;
float y = row;
float cx=(2*x-w)/h;
float cy=(2*y-h)/h;
float d=sqrtf(cx*cx+cy*cy);;
d-=0.5;
d+=0.01*h/(2*(x-y)+h-w);
d= fabsf(d);
d=0.1/d;
char c="-+=<@#"[(int)floorf(d/(1+d)*7)];
printf("%c%c",c,c);
}
printf("\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment