class SlideField::ObjectManager::Image

Public Instance Methods

on_draw(animator) click to toggle source
# File lib/slidefield/objects/image.rb, line 31
def on_draw(animator)
  tr = animator.transform @obj
  return if tr.skip_draw?

  x = @x + tr.x_offset
  y = @y + tr.y_offset

  x_scale = tr.scale * @x_scale
  y_scale = tr.scale * @y_scale

  color = @color.dup
  color.alpha = tr.opacity * @color.alpha

  @image.draw x, y, @z, x_scale, y_scale, color
end
on_load() click to toggle source
# File lib/slidefield/objects/image.rb, line 15
def on_load
  @x, @y = @obj.get :position
  @z = @obj.get :z_order
  @color = Gosu::Color.rgba *@obj.get(:color)

  source = File.expand_path @obj.get(:source), @obj.include_path
  width, height = @obj.get :size

  @image = Gosu::Image.new @window, source, true
  width = @image.width if 0 == width
  height = @image.height if 0 == height

  @x_scale = width / @image.width.to_f
  @y_scale = height / @image.height.to_f
end
on_unload() click to toggle source
# File lib/slidefield/objects/image.rb, line 47
def on_unload
  @image = nil
end