Class: CooCoo::Transformers::Image::Scaler

Inherits:
Base show all
Defined in:
lib/coo-coo/transformer.rb

Instance Attribute Summary

Attributes inherited from Base

#height, #width

Instance Method Summary collapse

Methods inherited from Base

#rotate, #scale, #translate

Methods inherited from Base

bin_op, bin_op_inner, #drop, #first

Constructor Details

#initialize(enum, width, height, scale_x, scale_y) ⇒ Scaler

Returns a new instance of Scaler.



191
192
193
194
195
# File 'lib/coo-coo/transformer.rb', line 191

def initialize(enum, width, height, scale_x, scale_y)
  super(enum, width, height)
  @scale_x = scale_x
  @scale_y = scale_y
end

Instance Method Details

#nextObject



197
198
199
200
201
202
203
204
205
206
# File 'lib/coo-coo/transformer.rb', line 197

def next
  i = super()
  r = NMatrix.zeroes([1, width * height])
  height.times do |y|
    width.times do |x|
      r[0, map_pixel(x, y)] = sample(i, x, y)
    end
  end
  r
end