Running with Shoes – Show Me More

This tutorial describes some of the basic graphic capabilities of the Shoes Ruby-based mini-GUI toolkit.

Shoes Fade
Here is a good example of Shoes oval method in action. For a lack of a better name I call this example Fade Into Black. It is just a series of circles getting 25%.

Shoes Fade

Here is the source code for the above image.

Shoes.app :width => 600, :height => 600 do
nostroke
draw_circle(self, 0.9, 600)
end

def draw_circle(app, color, size)
r = size/2
app.fill gray(color)
app.oval app.width/2 – r, 0, size, size
draw_circle(app, color – 0.04, 3*size/4) if (color > 0.4)
end

Shoes Worlds
Taking the above example one step further with using the mask method.

Shoes Worlds

Here is the source code for the above image.

Shoes.app :width => 600, :height => 600 do
nofill
draw_circle(self, 0.1, 600)
mask do
250.times do
x = (20..580).rand
y = (20..580).rand
s = (20..60).rand
oval x, y, s, s
end
end
end

def draw_circle(app, color, size)
r = size/2
app.fill blue(color)
app.oval app.width/2 – r, app.height/2 – r, size, size
draw_circle(app, color + 0.04, 3*size/4) if (color < 0.7)
end

Technorati Tags: , , , , , , ,

Related posts:

  1. Running with Shoes – 2D Graphics and Animation
  2. Running with Shoes – Colorfy
  3. Running with Shoes – 2D Examples
  4. Running with Shoes – Transform
  5. Running with Shoes – Shapely

This entry was posted in Ruby, TechKnow. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

2 Trackbacks

  1. By Morning Brew #84 on October 24, 2007 at 10:31 am

    [...] Ruby interface to Windows, Linux and OSX applications. Best for small utilities. (into one, two and three by [...]

  2. By Alex Gorbatchev » Morning Brew #84 on July 6, 2008 at 12:12 pm

    [...] Ruby interface to Windows, Linux and OSX applications. Best for small utilities. (into one, two and three by [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*