Sha256: bdde37387c2a006f5f45ef4bbf9c73c845be15f484c370e919896f82544bca31

Contents?: true

Size: 797 Bytes

Versions: 4

Compression:

Stored size: 797 Bytes

Contents

begin
  require 'oily_png'
rescue LoadError
  require 'chunky_png'
end

module Compass
  module SassExtensions
    module Sprites
      class ChunkyPngEngine < Compass::SassExtensions::Sprites::Engine

        def construct_sprite
          @canvas = ChunkyPNG::Image.new(width, height, ChunkyPNG::Color::TRANSPARENT)
          images.each do |image|
            input_png  = ChunkyPNG::Image.from_file(image.file)
            canvas.replace! input_png, image.left, image.top
          end
        end

        def save(filename)
          if canvas.nil?
            construct_sprite
          end

          Sass::Util.atomic_create_and_write_file(filename) do |file|
            canvas.write(file, Compass.configuration.chunky_png_options)
          end
        end

      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
compass-0.12.7 lib/compass/sass_extensions/sprites/engines/chunky_png_engine.rb
compass-0.12.6 lib/compass/sass_extensions/sprites/engines/chunky_png_engine.rb
compass-0.12.5 lib/compass/sass_extensions/sprites/engines/chunky_png_engine.rb
compass-0.12.4 lib/compass/sass_extensions/sprites/engines/chunky_png_engine.rb