Last active
December 14, 2015 03:59
-
-
Save tanmaykm/5025017 to your computer and use it in GitHub Desktop.
A Julia program to generate Julia set images.
Images are written on to stdout in PGM format. Args: image size (pixels. width and height are equal to this.) value of complex parameter real part value of complex parameter imaginary part Accompanying post at: http://sidekick.windforwings.com/2013/02/julia-sets-using-julia.html
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
# A Julia program to generate Julia set images. | |
# Images are written on to stdout in PGM format. | |
# Args: | |
# image size (pixels. width and height are equal to this. default 200) | |
# value of complex parameter real part (default 0) | |
# value of complex parameter imaginary part (default 0.65) | |
# Accompanying post at: http://sidekick.windforwings.com/2013/02/julia-sets-using-julia.html | |
w,h = 200 | |
c = 0 + 0.65im | |
if(length(ARGS) >= 3) | |
w,h = int(ARGS[1]) | |
c = float(ARGS[2]) + float(ARGS[3])*im | |
end | |
print("P2\n#Julia with Julia\n$(w) $(h)\n255\n") | |
for r_val in linspace(-2.0, 2.0, w), im_val in linspace(-2.0, 2.0, h) | |
z = r_val + im_val*im | |
n = 255 | |
while abs(z) < 10 && n >= 5 | |
z = z*z + c | |
n -= 5 | |
end | |
print("$n ") | |
if im_val == 2.0 | |
print("\n") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment