Sha256: 344d223b74a3070f4b8528ac856493a367a506fa6dd8f7dc92526b8dcd7981ff

Contents?: true

Size: 1.98 KB

Versions: 13

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.io
    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.io
    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

13 entries across 13 versions & 1 rubygems

Version Path
squib-0.15.3 lib/squib/api/image.rb
squib-0.15.0 lib/squib/api/image.rb
squib-0.14.3.pre1 lib/squib/api/image.rb
squib-0.14.1 lib/squib/api/image.rb
squib-0.14.0 lib/squib/api/image.rb
squib-0.14.beta1 lib/squib/api/image.rb
squib-0.13.4 lib/squib/api/image.rb
squib-0.13.3 lib/squib/api/image.rb
squib-0.13.2 lib/squib/api/image.rb
squib-0.13.1 lib/squib/api/image.rb
squib-0.13.0 lib/squib/api/image.rb
squib-0.12.0 lib/squib/api/image.rb
squib-0.11.0 lib/squib/api/image.rb