Skip to content

Instantly share code, notes, and snippets.

@jamesarosen
Created February 12, 2010 22:37
Show Gist options
  • Save jamesarosen/303065 to your computer and use it in GitHub Desktop.
Save jamesarosen/303065 to your computer and use it in GitHub Desktop.
A pretty fractal in Ruby
#!/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