Skip to content

Instantly share code, notes, and snippets.

@r1r11
Created April 27, 2019 22:56
Show Gist options
  • Save r1r11/e0f6583cba68181a126a2ea46077fac7 to your computer and use it in GitHub Desktop.
Save r1r11/e0f6583cba68181a126a2ea46077fac7 to your computer and use it in GitHub Desktop.
const colors = split(' ,.,.,-,-,_,+,+,/,=,L,7,H,%,#,@', ',');
let darken = fn(int idx, int darkness) {
if (idx > darkness) {
return idx - darkness;
} else {
return 0;
}
}
let spiral = fn(int idx, int x, int y, int cx, int cy, int radius) {
float waveX = Math.abs(Math.sin((cx-x) / (Math.PI() / radius))),
waveY = Math.abs(Math.cos((cy-y*2) / (Math.PI() / radius)));
int value = Math.floor((waveX * waveY*10));
if (value > 16) {
value = 16;
}
if (value < 0) {
value = 0;
}
return value;
}
let circle = fn(int x, int y, int cx, int cy, int cr) {
int dx = x-cx,
dy = y-cy;
return (dx*dx/3.8)+(dy*dy) < (cr*cr);
}
for (y, 80) {
string s = '-';
string line = ' ';
int idx = 0;
for (x, 160) {
idx = ((x%y)+x*x)%16;
if (circle(x, y, 80, 40, 40)) {
idx = darken(idx, 5);
}
if (circle(x, y, 80, 40, 30)) {
idx = spiral(darken(idx, 2), x, y, 80, 40, 5);
}
if (circle(x, y, 80, 40, 15)) {
idx = darken(idx, 4);
}
string line = colors[idx];
let s = s + line;
}
print(s);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment