Sierpinski's shoes

Posted by Jonas Elfström Wed, 14 Nov 2007 22:50:00 GMT

There were no cross-platform windowing toolkits for Ruby so _why made one and he calls it Shoes. Not even close to 1.0, it's already yummy in a chunky kind of way and since it came from _why I simply had to try it out. Something simple.

Shoes.app :width => 1024, :height => 768 do  
  corners = [ {:x => 256, :y => 10}, {:x => 12, :y => 378}, {:x => 506, :y => 378} ]
  xpos,ypos,c = 256,10,0
  srand
  2111.times do
      c=rand(3)
      xpos += (corners[c][:x]-xpos)>>1
      ypos += (corners[c][:y]-ypos)>>1
      star xpos, ypos, 5, 10
  end
end

The result.

Posted in Ruby, Math | 1 comment

Comments

    1. Avatar
      Ruben Berenguel Thu, 23 Sep 2010 21:28:25 GMT

      Okay, the first thought I got was “Oh my God, is full of stars!”. I guess I am too geeky.

      I think this is the first time I’ve seen ruby code! For some reason or other, I have been avoiding the language.

      Cheers,

      Ruben

Comments are closed