------ art_15674_31724723.1213693810398
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Here's mine
# initial values
r RGV[0].to_i; k 60.0/(Math::PI*2)
# if r < 1 write error and exit
puts "USAGE: circle.rb radius [with radius > ]"; exit if r < 1
# get some points and map them on a matrix
m rray.new(r).collect{|e|Array.new(r).fill(" ")}
j 0.0,90.0,*(1...p vr -1))*2)).to_a.collect{|e|
e*(90.0/p.to_f) }].each{|a|
vl ath.sin(a/k),Math.cos(a/k)].collect{|c| (c*vr).round }
m[vl[0]][vl[1]] " }
s .collect{|a| w ¨Âïé¢©» ÷®òåöåòóå«ý®êïéÜ
# print the result
puts s.reverse+"\n"+s
On Mon, Jun 16, 2008 at 3:54 PM, Jon Garvin <jgarvin.lists / gmail.com> wrote:
> Here's mine before I delved into trying to add the aspect ratio feature.
>
>
> class Circle
> def initialize(radius)
> @radius adius.to_i
> end
>
> def draw
> (0..@radius*2).each do |x|
> (0..@radius*2).each do |y|
> print distance_from_center(x,y).round @radius ? '#' : '.'
> end
> puts
> end
> end
>
> def distance_from_center(x,y)
> a alc_side(x)
> b alc_side(y)
> return Math.sqrt(a**2 + b**2)
> end
>
> def calc_side(z)
> z < @radius ? (@radius - z) : (z - @radius)
> end
> end
>
> Circle.new(ARGV.shift).draw
>
> --
>
> http://www.5valleys.com/
>
> http://www.workingwithrails.com/person/8078
>
>
>
--
Go outside! The graphics are amazing!
------ art_15674_31724723.1213693810398--