Class: Axon::Fit
- Inherits:
-
Object
- Object
- Axon::Fit
- Defined in:
- lib/axon/fit.rb
Overview
Instance Method Summary collapse
-
#color_model ⇒ Object
Gets the color model of the fitted image.
-
#components ⇒ Object
Gets the components in the fitted image.
-
#gets ⇒ Object
Gets the next scanline from the fitted image.
-
#height ⇒ Object
Gets the height of the fitted image.
-
#initialize(source, width, height) ⇒ Fit
constructor
:call-seq: Fit.new(image_in, width, height).
-
#lineno ⇒ Object
Gets the index of the next line that will be fetched by gets, starting at 0.
-
#width ⇒ Object
Gets the width of the fitted image.
Constructor Details
#initialize(source, width, height) ⇒ Fit
:call-seq:
Fit.new(image_in, width, height)
Fits image_in
in the box dimensions given by width
and height
. The resulting image will not extend beyond the given width
or the given height
. The resulting image will maintain the aspect ratio of image_in
so the resulting image may not completely fill width
and height
.
The resulting image will match either width
or height
.
28 29 30 31 |
# File 'lib/axon/fit.rb', line 28 def initialize(source, width, height) @source, @fit_width, @fit_height = source, width, height @scaler = nil end |
Instance Method Details
#color_model ⇒ Object
Gets the color model of the fitted image. Same as the color model of the source image.
43 44 45 |
# File 'lib/axon/fit.rb', line 43 def color_model @source.color_model end |
#components ⇒ Object
Gets the components in the fitted image. Same as the components of the source image.
36 37 38 |
# File 'lib/axon/fit.rb', line 36 def components @source.components end |
#gets ⇒ Object
Gets the next scanline from the fitted image.
69 70 71 72 |
# File 'lib/axon/fit.rb', line 69 def gets @scaler ||= get_scaler @scaler.gets end |
#height ⇒ Object
Gets the height of the fitted image. This will be the given height or less.
56 57 58 |
# File 'lib/axon/fit.rb', line 56 def height @scaler ? @scaler.height : calculate_height end |
#lineno ⇒ Object
Gets the index of the next line that will be fetched by gets, starting at 0.
63 64 65 |
# File 'lib/axon/fit.rb', line 63 def lineno @scaler ? @scaler.lineno : 0 end |
#width ⇒ Object
Gets the width of the fitted image. This will be the given width or less.
49 50 51 |
# File 'lib/axon/fit.rb', line 49 def width @scaler ? @scaler.width : calculate_width end |