Sha256: 3582ea29fd6c70700a61800eed44f80bd5feff598f1e2f2bd8736db1f4e7244c

Contents?: true

Size: 1.98 KB

Versions: 1

Compression:

Stored size: 1.98 KB

Contents

require_relative '../args/card_range'
require_relative '../args/paint'
require_relative '../args/scale_box'
require_relative '../args/transform'
require_relative '../args/input_file'
require_relative '../args/svg_special'

module Squib
  class Deck

    # DSL method. See http://squib.readthedocs.org
    def png(opts = {})
      Dir.chdir(img_dir) do
        range = Args::CardRange.new(opts[:range], deck_size: size)
        paint = Args::Paint.new(custom_colors).load!(opts, expand_by: size, layout: layout)
        box   = Args::ScaleBox.new(self).load!(opts, expand_by: size, layout: layout, dpi: dpi)
        trans = Args::Transform.new(self).load!(opts, expand_by: size, layout: layout, dpi: dpi)
        ifile = Args::InputFile.new.load!(opts, expand_by: size, layout: layout, dpi: dpi)
        @progress_bar.start('Loading PNG(s)', range.size) do |bar|
          range.each do |i|
            @cards[i].png(ifile[i].file, box[i], paint[i], trans[i])
            bar.increment
          end
        end
      end
    end

    # DSL method. See http://squib.readthedocs.org
    def svg(opts = {})
      Dir.chdir(img_dir) do
        range = Args::CardRange.new(opts[:range], deck_size: size)
        paint = Args::Paint.new(custom_colors).load!(opts, expand_by: size, layout: layout)
        box   = Args::ScaleBox.new(self).load!(opts, expand_by: size, layout: layout, dpi: dpi)
        trans = Args::Transform.new(self).load!(opts, expand_by: size, layout: layout, dpi: dpi)
        ifile = Args::InputFile.new.load!(opts, expand_by: size, layout: layout, dpi: dpi)
        svg_args = Args::SvgSpecial.new.load!(opts, expand_by: size, layout: layout, dpi: dpi)
        @progress_bar.start('Loading SVG(s)', range.size) do |bar|
          range.each do |i|
            if svg_args.render?(i)
              @cards[i].svg(ifile[i].file, svg_args[i], box[i], paint[i], trans[i])
            end
            bar.increment
          end
        end
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
squib-0.10.0 lib/squib/api/image.rb