Class: CooCoo::Transformers::Image::Translation

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, tx, ty) ⇒ Translation

Returns a new instance of Translation.



113
114
115
116
117
# File 'lib/coo-coo/transformer.rb', line 113

def initialize(enum, width, height, tx, ty)
  super(enum, width, height)
  @tx = tx
  @ty = ty
end

Instance Method Details

#nextObject



119
120
121
122
123
124
125
126
127
128
# File 'lib/coo-coo/transformer.rb', line 119

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