Class: Sprite::Frame
- Inherits:
-
Object
- Object
- Sprite::Frame
- Defined in:
- lib/rmagick-sprite/frame.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#sprite ⇒ Object
readonly
Returns the value of attribute sprite.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
-
#x ⇒ Object
readonly
Returns the value of attribute x.
-
#y ⇒ Object
readonly
Returns the value of attribute y.
Instance Method Summary collapse
- #image ⇒ Object
-
#initialize(options) ⇒ Frame
constructor
A new instance of Frame.
- #reload ⇒ Object
Constructor Details
#initialize(options) ⇒ Frame
Returns a new instance of Frame.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rmagick-sprite/frame.rb', line 6 def initialize() raise 'options must be a Hash' unless .respond_to?(:to_hash) || .respond_to?(:to_h) = .to_hash rescue .to_h raise 'options[:action] must be given' if [:action].nil? raise 'options[:action] must be an Action' unless [:action].instance_of?(Action) raise 'options[:x] must be given' if [:x].nil? raise 'options[:x] must be a Integer-like object' unless [:x].respond_to?(:to_i) raise 'options[:y] must be given' if [:y].nil? raise 'options[:y] must be a Integer-like object' unless [:y].respond_to?(:to_i) raise 'options[:width] must be given' if [:width].nil? raise 'options[:width] must be a Integer-like object' unless [:width].respond_to?(:to_i) raise 'options[:height] must be given' if [:height].nil? raise 'options[:height] must be a Integer-like object' unless [:height].respond_to?(:to_i) @action = [:action] @x, @y, @width, @height = .values_at(:x, :y, :width, :height).collect(&:to_i) @sprite = @action.sprite end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
4 5 6 |
# File 'lib/rmagick-sprite/frame.rb', line 4 def action @action end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
4 5 6 |
# File 'lib/rmagick-sprite/frame.rb', line 4 def height @height end |
#sprite ⇒ Object (readonly)
Returns the value of attribute sprite.
4 5 6 |
# File 'lib/rmagick-sprite/frame.rb', line 4 def sprite @sprite end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
4 5 6 |
# File 'lib/rmagick-sprite/frame.rb', line 4 def width @width end |
#x ⇒ Object (readonly)
Returns the value of attribute x.
4 5 6 |
# File 'lib/rmagick-sprite/frame.rb', line 4 def x @x end |
#y ⇒ Object (readonly)
Returns the value of attribute y.
4 5 6 |
# File 'lib/rmagick-sprite/frame.rb', line 4 def y @y end |
Instance Method Details
#image ⇒ Object
26 27 28 29 30 |
# File 'lib/rmagick-sprite/frame.rb', line 26 def image reload if @image.nil? @image end |
#reload ⇒ Object
32 33 34 |
# File 'lib/rmagick-sprite/frame.rb', line 32 def reload @image = @sprite.image.excerpt(@x, @y, @width, @height) end |