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.

[source:ruby]
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
[/source]

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.

[source:ruby]
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 [/source]

Technorati Tags: , , , , , , ,


2 Responses to “Running with Shoes – Show Me More”

Leave a Reply