lib/cyberarm_engine/ui/elements/image.rb in cyberarm_engine-0.14.0 vs lib/cyberarm_engine/ui/elements/image.rb in cyberarm_engine-0.15.0

- old
+ new

@@ -4,30 +4,32 @@ def initialize(path, options = {}, block = nil) super(options, block) @path = path @image = Gosu::Image.new(path, retro: @options[:image_retro]) - @scale_x, @scale_y = 1, 1 + @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) # TODO: Add color support? + @scale_x, @scale_y, @style.color + ) end - def clicked_left_mouse_button(sender, x, y) + def clicked_left_mouse_button(_sender, _x, _y) @block.call(self) if @block - return :handled + :handled end def recalculate _width = dimensional_size(@style.width, :width) - _height= dimensional_size(@style.height,:height) + _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 @@ -35,18 +37,19 @@ @scale_y = @scale_x elsif _height @scale_y = _height.to_f / @image.height @scale_x = @scale_y else - @scale_x, @scale_y = 1, 1 + @scale_x = 1 + @scale_y = 1 end - @width = _width ? _width : @image.width.round * @scale_x - @height= _height ? _height : @image.height.round * @scale_y + @width = _width || @image.width.round * @scale_x + @height = _height || @image.height.round * @scale_y end def value @path end end end -end \ No newline at end of file +end