Skip to content

Latest commit

 

History

History
37 lines (29 loc) · 1.06 KB

00511_Drawing_directly_on_to_images.mdown

File metadata and controls

37 lines (29 loc) · 1.06 KB

Drawing directly onto images

It's possible to add elements to an image.
In the following example Cy (the green creature) had a star added to it.

# sample25.rb
Shoes.app :width => 250, :height => 76 do
  background lightsalmon
  icon = image :width => 74, :height => 74 do
    oval :width => 70, :height => 70, :fill => lightskyblue,
          :stroke => red, :left => 2, :top => 2
  end
  icon.image '../images/cy.png', :left => 10, :top => 8
  icon.star 35, 45, 5, 8, 3, :fill => hotpink, :stroke => nil
  msg = para '', :stroke => white
  
  icon.hover do
    @a = animate do
      button, left, top = self.mouse
      msg.replace strong icon[left, top]
    end
  end
  icon.leave do
    @a.stop
    msg.replace ''
  end
end

sample25.png

sample25.png

Please note that if you are using Shoes-0.r970, you need to move the mouse off the image once. After that it will works as expected.
With Shoes-0.r1057, there is no need to do this.