module SpriteFactory::Library::ChunkyPng

Constants

VALID_EXTENSIONS

Public Class Methods

create(filename, images, width, height) click to toggle source
# File lib/sprite_factory/library/chunky_png.rb, line 21
def self.create(filename, images, width, height)
  target = ChunkyPNG::Image.new(width, height, ChunkyPNG::Color::TRANSPARENT)
  images.each do |image|
    target.compose!(image[:image], image[:x], image[:y])
  end
  target.save(filename)
end
load(files) click to toggle source
# File lib/sprite_factory/library/chunky_png.rb, line 9
def self.load(files)
  files.map do |filename|
    image = ChunkyPNG::Image.from_file(filename)
    {
      :filename => filename,
      :image    => image,
      :width    => image.width,
      :height   => image.height
    }
  end
end