Sha256: f8d75bd3913caa739f71eda4468fa2a400df5eb8e0f9d07ba28911efc366c409
Contents?: true
Size: 1.35 KB
Versions: 1
Compression:
Stored size: 1.35 KB
Contents
module CyberarmEngine class Element class Image < Element def initialize(path, options = {}, block = nil) super(options, block) @path = path @image = Gosu::Image.new(path, retro: @options[:image_retro]) @scale_x = 1 @scale_y = 1 end def render @image.draw( @style.border_thickness_left + @style.padding_left + @x, @style.border_thickness_top + @style.padding_top + @y, @z + 2, @scale_x, @scale_y, @style.color ) end def clicked_left_mouse_button(_sender, _x, _y) @block.call(self) if @block :handled end def recalculate _width = dimensional_size(@style.width, :width) _height = dimensional_size(@style.height, :height) if _width && _height @scale_x = _width.to_f / @image.width @scale_y = _height.to_f / @image.height elsif _width @scale_x = _width.to_f / @image.width @scale_y = @scale_x elsif _height @scale_y = _height.to_f / @image.height @scale_x = @scale_y else @scale_x = 1 @scale_y = 1 end @width = _width || @image.width.round * @scale_x @height = _height || @image.height.round * @scale_y end def value @path end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cyberarm_engine-0.15.0 | lib/cyberarm_engine/ui/elements/image.rb |