class Fidgit::ImageFrame
A wrapper around a Gosu::Image to show it in the GUI.
Constants
- DISABLED_COLOR
- ENABLED_COLOR
Attributes
factor_x[R]
factor_y[R]
image[R]
Public Class Methods
new(image, options = {})
click to toggle source
@param (see Element#initialize) @param [Gosu::Image] image Gosu
image to display.
@option (see Element#initialize) @option options [Boolean] :thumbnail (false) Is the image expanded to be square?
Calls superclass method
Fidgit::Element::new
# File lib/fidgit/elements/image_frame.rb, line 16 def initialize(image, options = {}) options = { thumbnail: false, factor: 1, }.merge! options @thumbnail = options[:thumbnail] @factor_x = options[:factor_x] || options[:factor] @factor_y = options[:factor_y] || options[:factor] super(options) self.image = image end
Public Instance Methods
draw_foreground()
click to toggle source
# File lib/fidgit/elements/image_frame.rb, line 40 def draw_foreground @image.draw(x + padding_left, y + padding_top, z, factor_x, factor_y, enabled? ? ENABLED_COLOR : DISABLED_COLOR) if @image end
image=(image)
click to toggle source
# File lib/fidgit/elements/image_frame.rb, line 31 def image=(image) @image = image recalc image end
thumbnail?()
click to toggle source
# File lib/fidgit/elements/image_frame.rb, line 9 def thumbnail?; @thumbnail; end
Protected Instance Methods
layout()
click to toggle source
# File lib/fidgit/elements/image_frame.rb, line 45 def layout if @image if @thumbnail size = [@image.width, @image.height].max rect.width = size * @factor_x rect.height = size * @factor_y else rect.width = @image.width * @factor_x rect.height = @image.height * @factor_y end else rect.width = rect.height = 0 end rect.width += padding_left + padding_right rect.height += padding_top + padding_bottom nil end