class Pixelart::Image

Constants

PIXEL_OFFSETS

Public Instance Methods

pixelate( *args, **kwargs )
Alias for: sample
sample( *args, **kwargs ) click to toggle source
# File lib/artbase/image.rb, line 9
def sample( *args, **kwargs )
  ## note: for now always assume square image (e.g. 24x24, 32x32 and such)

  offsets = if kwargs[:from] && kwargs[:to]
              PIXEL_OFFSETS[ kwargs[:to] ][ kwargs[ :from ]]
            else
              args[0]   ## assume "custom" hash of offsets
            end

  width = height = offsets.size

  puts "     #{self.width}x#{self.height} => #{width}x#{height}"


  dest = Image.new( width, height )

  offsets.each do |offset_x, x|
    offsets.each do |offset_y, y|
       pixel = self[offset_x,offset_y]

       dest[x,y] =  pixel
    end
  end

  dest
end
Also aliased as: pixelate