Sha256: 1c04c4e98bbced4f8a33c35e14a44eebf01d4d3be806e24b29db6162b5578dfe

Contents?: true

Size: 891 Bytes

Versions: 4

Compression:

Stored size: 891 Bytes

Contents

module Squib
  class Card

    # :nodoc:
    # @api private
    def save_png(i, dir, prefix, do_rotate, angle)
      if [true, :clockwise, :counterclockwise].include?(do_rotate)
        surface = rotated_image(angle)
      else
        surface = @cairo_surface
      end
      write_png(surface, i, dir, prefix)
    end

    # :nodoc:
    # @api private
    def rotated_image(angle)
      rotated_cc = Cairo::Context.new(Cairo::ImageSurface.new(@height, @width) )
      rotated_cc.translate(@height * 0.5, @width * 0.5)
      rotated_cc.rotate(angle)
      rotated_cc.translate(@width * -0.5, @height * -0.5)
      rotated_cc.set_source(@cairo_surface)
      rotated_cc.paint
      rotated_cc.target
    end
    # :nodoc:
    # @api private
    def write_png(surface, i, dir, prefix)
      surface.write_to_png("#{dir}/#{prefix}#{i}.png")
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
squib-0.2.0 lib/squib/graphics/save_images.rb
squib-0.1.0 lib/squib/graphics/save_images.rb
squib-0.0.6 lib/squib/graphics/save_images.rb
squib-0.0.5 lib/squib/graphics/save_images.rb