Sha256: d124963cabfb692769885383cede877982928b05c494dc63a01b80befa554ee5

Contents?: true

Size: 780 Bytes

Versions: 23

Compression:

Stored size: 780 Bytes

Contents

require 'chunky_png'

module SpriteFactory
  module Library
    module ChunkyPng

      VALID_EXTENSIONS = :png

      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

      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

    end # module ChunkyPng
  end # module Library
end # module SpriteFactory

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
sprite-factory-1.7.1 lib/sprite_factory/library/chunky_png.rb
sprite-factory-1.7 lib/sprite_factory/library/chunky_png.rb
sprite-factory-1.6.2 lib/sprite_factory/library/chunky_png.rb
sprite-factory-1.6.1 lib/sprite_factory/library/chunky_png.rb
sprite-factory-custom-1.6.4.5 lib/sprite_factory/library/chunky_png.rb
sprite-factory-custom-1.6.4.4 lib/sprite_factory/library/chunky_png.rb
sprite-factory-custom-1.6.4.3 lib/sprite_factory/library/chunky_png.rb
sprite-factory-custom-1.6.4.2 lib/sprite_factory/library/chunky_png.rb
sprite-factory-custom-1.6.4.1 lib/sprite_factory/library/chunky_png.rb
sprite-factory-custom-1.6.3 lib/sprite_factory/library/chunky_png.rb
sprite-factory-custom-1.6.2 lib/sprite_factory/library/chunky_png.rb
sprite-factory-custom-1.6.1 lib/sprite_factory/library/chunky_png.rb
sprite-factory-custom-1.6.0 lib/sprite_factory/library/chunky_png.rb
sprite-factory-1.6.0 lib/sprite_factory/library/chunky_png.rb
sprite-factory-1.5.3 lib/sprite_factory/library/chunky_png.rb
sprite-factory-1.5.2 lib/sprite_factory/library/chunky_png.rb
sprite-factory-1.5.1 lib/sprite_factory/library/chunky_png.rb
sprite-factory-1.5.0 lib/sprite_factory/library/chunky_png.rb
sprite-factory-1.4.2 lib/sprite_factory/library/chunky_png.rb
sprite-factory-1.4.1 lib/sprite_factory/library/chunky_png.rb