Created
February 12, 2010 22:37
-
-
Save jamesarosen/303065 to your computer and use it in GitHub Desktop.
A pretty fractal in Ruby
This file contains hidden or 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
#!/usr/bin/env ruby | |
# adapted from Karl von Laudermann's one-liner version | |
require "complex" | |
w = 39 | |
m = 2.0 | |
w.times do |y| | |
w.times do |x| | |
c = Complex.new((m*x/w)-1.5,(2.0*y/w)-1.0) | |
z = c | |
e = false | |
49.times do | |
z = z*z+c | |
if z.abs > m | |
e = true | |
break | |
end | |
end | |
print(e ?" ":"@@") | |
end | |
puts | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment