Class: Fidgit::Thumbnail
Overview
Wrapper for Gosu::Image that always pads the image out to being square.
Constant Summary collapse
- DEFAULT_COLOR =
Gosu::Color.rgb(255, 255, 255)
Instance Attribute Summary collapse
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#image ⇒ Object
Returns the value of attribute image.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
- #draw(x, y, z_order, scale_x = 1, scale_y = 1, color = DEFAULT_COLOR, mode = :default) ⇒ Object
-
#initialize(image) ⇒ Thumbnail
constructor
A new instance of Thumbnail.
Constructor Details
#initialize(image) ⇒ Thumbnail
Returns a new instance of Thumbnail.
18 19 20 21 |
# File 'lib/fidgit/thumbnail.rb', line 18 def initialize(image) raise ArgumentError, "image must be a Gosu::Image" unless image.is_a? Gosu::Image self.image = image end |
Instance Attribute Details
#height ⇒ Object (readonly)
Returns the value of attribute height.
8 9 10 |
# File 'lib/fidgit/thumbnail.rb', line 8 def height @height end |
#image ⇒ Object
Returns the value of attribute image.
8 9 10 |
# File 'lib/fidgit/thumbnail.rb', line 8 def image @image end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
8 9 10 |
# File 'lib/fidgit/thumbnail.rb', line 8 def width @width end |
Instance Method Details
#draw(x, y, z_order, scale_x = 1, scale_y = 1, color = DEFAULT_COLOR, mode = :default) ⇒ Object
23 24 25 26 27 |
# File 'lib/fidgit/thumbnail.rb', line 23 def draw(x, y, z_order, scale_x = 1, scale_y = 1, color = DEFAULT_COLOR, mode = :default) @image.draw x + (@width - @image.width) * scale_x / 2, y + (@height - @image.height) * scale_y / 2, z_order, scale_x, scale_y, color, mode nil end |