2008/10/12

Optional Arguments

We can use the :center option to specify the coordinates. But it works well only in the case of the oval and rect methods except the star method. If we add undefined option, like :oops, as one of the arguments, no error will occur and nothing will happen, just ignored. Now I mention about Shoes-0.r970 on Windows XP.

# sample40-1.rb
Shoes.app do
stack :width => 0.3 do
nofill
strokewidth 2
oval 50, 50, 1, :stroke => red, :fill => red
@o = oval 50, 50, 50, :stroke => blue, :center => false, :oops => true
@p1 = para '', :top => 150
end

stack :width => 0.3 do
nofill
strokewidth 2
oval 50, 50, 1, :stroke => red, :fill => red
@r = rect 50, 50, 50, 50, :stroke => green, :center => true, :oops => true
@p2 = para '', :top => 150
end

stack :width => 0.4 do
nofill
strokewidth 2
oval 50, 50, 1, :stroke => red, :fill => red
@s = star 50, 50, 5, 30, 20, :stroke => black, :center => false, :oops => true
@p3 = para '', :top => 150
end

@p1.text = @o.style.map{|e| e.join(': ')}.sort.join("\n")
@p2.text = @r.style.map{|e| e.join(': ')}.sort.join("\n")
@p3.text = @s.style.map{|e| e.join(': ')}.sort.join("\n")
end

# sample41-1.png


I'm not sure if the above behavior is useful, though... :-P

ashbb

ps. Updated my Shoes Tutorial Note to r081013 on Github. Included this topic, too.

No comments:

O'Reilly Ruby Books

Twitter Updates

    follow me on Twitter