Created
February 25, 2013 03:19
-
-
Save dhotson/5027232 to your computer and use it in GitHub Desktop.
A screensaver in Julia
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
pallete = Array(String, 93) | |
i = 1 | |
for bg = 232:(255-1) | |
for char in [" ", "░", "▒", "▓"] | |
pallete[i] = "\e[38;5;$(bg+1)m\e[48;5;$(bg)m$(char)\e[0m" | |
i += 1 | |
end | |
end | |
pallete[93] = "\e[48;5;$(255)m \e[0m" | |
cols = float(readall(`tput cols`)) | |
lines = float(readall(`tput lines`)) | |
print("\e[?25l") | |
bound(i) = max(1, min(93, int(i))) | |
for i = 1:1000 | |
t = time() | |
print("\e[H") | |
for yy = 1.0:lines | |
y = yy*1.6 # Try to adjust for aspect ratio | |
for x = 1.0:cols | |
i = 47 * (cos(sin(x/3.3) + sin(sin(x/4) + cos(y/5.4)) + t) * sin(sqrt(((x-cols/2)/2)^2 + ((y-(lines*1.6)/2)/2)^2)/2 - t*5)) + 46 | |
print(pallete[bound(i)]) | |
end | |
if yy != lines; println(); end | |
end | |
print("\e[0m") | |
end | |
print("\e[?25h") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment