Skip to content

Latest commit

 

History

History
32 lines (23 loc) · 867 Bytes

00537_One_way_of_layer_manipulation.mdown

File metadata and controls

32 lines (23 loc) · 867 Bytes

One way of layer manipulation

Usually the later-made Shape instances are layouted on the early-made ones. So, attempted to write a code to swap the layers between them.

# sample64.rb
Shoes.app :width => 300, :height => 300 do
  def swap s1, s2
    tmp = s2.style.to_a
    s1.style.to_a.each{|k, v| s2.style k => v}
    tmp.each{|k, v| s1.style k => v}
  end

  nostroke
  r1 = rect 50, 50, 100, 100, :fill => mediumslateblue
  r2 = rect 100, 100, 100, 100, :fill => sandybrown
  r3 = rect 150, 150, 100, 100, :fill => orchid
  
  button('swap 1-2'){swap r1, r2}
  button('swap 2-3'){swap r2, r3}
  button('swap 1-3'){swap r1, r3}
end

sample64.png

sample64.png

Policeman

The sample64.rb worked well with Shoes-0.r1263