class CooCoo::Image::TransformedImage

Public Class Methods

new(image, transform, filter = nil) click to toggle source
# File lib/coo-coo/image.rb, line 79
def initialize(image, transform, filter = nil)
  @image = image
  @transform = transform
  @filter = filter
end

Public Instance Methods

*(transform) click to toggle source
# File lib/coo-coo/image.rb, line 97
def *(transform)
  t = if @transform
        TransformChain.new(@transform, transform)
      else
        transform
      end
  TransformedImage.new(@image, t, @filter)
end
[](x, y, byte = nil) click to toggle source
# File lib/coo-coo/image.rb, line 114
def [](x, y, byte = nil)
  x, y = *transform(x, y)
  p = @image[x, y, byte]
  filter(p, x, y)
end
bpp() click to toggle source
# File lib/coo-coo/image.rb, line 93
def bpp
  @image.bpp
end
filter(pixel, x, y) click to toggle source
# File lib/coo-coo/image.rb, line 120
def filter(pixel, x, y)
  if @filter
    @filter.call(pixel, x, y)
  else
    pixel
  end
end
height() click to toggle source
# File lib/coo-coo/image.rb, line 89
def height
  @image.height
end
to_a() click to toggle source
# File lib/coo-coo/image.rb, line 106
def to_a
  height.times.collect do |y|
    width.times.collect do |x|
      self[x, y]
    end.flatten
  end
end
transform(x, y) click to toggle source
# File lib/coo-coo/image.rb, line 128
def transform(x, y)
  if @transform
    @transform.call(x, y)
  else
    [ x, y ]
  end
end
width() click to toggle source
# File lib/coo-coo/image.rb, line 85
def width
  @image.width
end