Skip to content

Instantly share code, notes, and snippets.

@zphixon
Last active October 14, 2021 04:10
Show Gist options
  • Save zphixon/fe3ff4b12662d9c4f8017cf71b5b4c16 to your computer and use it in GitHub Desktop.
Save zphixon/fe3ff4b12662d9c4f8017cf71b5b4c16 to your computer and use it in GitHub Desktop.
use std::f64::consts::PI;
fn main() {
for y in (-25..25).filter(|x| x % 2 == 0) {
for x in -25..25 {
let r = ((x * x + y * y) as f64).sqrt() as i32;
let t = (((y as f64 / x as f64).atan() + PI / 2.0) * PI) - PI / 2.0;
if r < 25 && r > 12 {
let diff = 25 - r;
let line = (if t < 0.0 {
1.0 - (-t / PI / 2.0)
} else {
t / (PI / 2.0)
} * 12.5) as i32;
if (line - diff).abs() < 2 {
print!("\x1b[48;5;231m.\x1b[0m");
} else {
print!("\x20");
}
} else if r < 8 {
print!("\x20");
} else {
print!("\x1b[48;5;231m.\x1b[0m");
}
}
println!();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment