# ashbb/shoes_tutorial_html

Fetching contributors…
Cannot retrieve contributors at this time
77 lines (58 sloc) 2.49 KB

## optional arguments

When we create an oval shape, like
oval :left => 50, :top => 50, :width => 30
The :left and :top positions are the top-left corner of the oval.

But we create an star shape, like
star :left => 50, :top => 50, :points => 5, :outer => 15, :inner => 10
The :left and :top positions are the center of the star.
A bit strange behavior...

This information was provided by Sergio Silva.

``````# sample40.rb
Shoes.app :width => 330, :height => 150 do
nofill
strokewidth 2
oval 50, 50, 50, :stroke => blue
rect 150, 50, 50, 50, :stroke => green
star 250, 50, 5, 30, 20, :stroke => black
oval 50, 50, 1, :stroke => red, :fill => red
oval 150, 50, 1, :stroke => red, :fill => red
oval 250, 50, 1, :stroke => red, :fill => red
end
``````

sample40.png

We can use the :center option to specify the coordinates. But it works well only in the case of the oval and rect, not the star method. If we add an undefined option like :oops as one of the arguments, no error will occur and nothing will happen, it will just be ignored.

I don't know if this behavior is a spec or a bug...

``````# 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
``````

sample40-1.png

In the above sample40-1, the oval and rect methods accepted the :center option, but the star method ignored it as it ignored the undefined option :oops.

## Policeman

The sample40.rb and sample40-1.rb worked with Shoes-0.r1263 as same as Raisins.