Class: CooCoo::Image::Clipper

Inherits:
Transform show all
Defined in:
lib/coo-coo/image.rb

Instance Method Summary collapse

Methods inherited from Transform

#*

Constructor Details

#initialize(width, height) ⇒ Clipper

Returns a new instance of Clipper.



162
163
164
165
# File 'lib/coo-coo/image.rb', line 162

def initialize(width, height)
  @width = width
  @height = height
end

Instance Method Details

#call(pixel, x, y) ⇒ Object



167
168
169
170
171
172
173
# File 'lib/coo-coo/image.rb', line 167

def call(pixel, x, y)
  if x < 0 || x >= @width || y < 0 || y >= @height
    Array.new(pixel.size, 0.0)
  else
    pixel
  end
end