class CooCoo::Transformers::Image::Translation
Public Class Methods
new(enum, width, height, tx, ty)
click to toggle source
Calls superclass method
CooCoo::Transformers::Image::Base::new
# File lib/coo-coo/transformer.rb, line 113 def initialize(enum, width, height, tx, ty) super(enum, width, height) @tx = tx @ty = ty end
Public Instance Methods
next()
click to toggle source
Calls superclass method
CooCoo::Transformers::Proxy#next
# 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
Private Instance Methods
map_pixel(x, y)
click to toggle source
# File lib/coo-coo/transformer.rb, line 132 def map_pixel(x, y) x + y * width end
translate_pixel(x, y)
click to toggle source
# File lib/coo-coo/transformer.rb, line 136 def translate_pixel(x, y) [ (x + @tx) % width, (y + @ty) % height ] end