Sha256: 5538a15ca6ae84b89cf2e0fc42f33896e4271a7d35c18601f6a0d76fb65d3716

Contents?: true

Size: 1.48 KB

Versions: 3

Compression:

Stored size: 1.48 KB

Contents

require_relative '../errors_warnings/warn_unexpected_params'
require_relative '../args/card_range'
require_relative '../args/paint'
require_relative '../args/scale_box'
require_relative '../args/transform'
require_relative '../args/input_file'

module Squib
  class Deck
    def png(opts = {})
      DSL::PNG.new(self, __callee__).run(opts)
    end
  end

  module DSL
    class PNG
      include WarnUnexpectedParams
      attr_reader :dsl_method, :deck

      def initialize(deck, dsl_method)
        @deck = deck
        @dsl_method = dsl_method
      end

      def self.accepted_params
        %i(
          file
          x y width height
          alpha blend mask angle
          crop_x crop_y crop_width crop_height
          crop_corner_radius crop_corner_x_radius crop_corner_y_radius
          flip_horizontal flip_vertical
          range layout
          placeholder
         )
      end

      def run(opts)
        warn_if_unexpected opts
        Dir.chdir(deck.img_dir) do
          range = Args.extract_range opts, deck
          paint = Args.extract_paint opts, deck
          box   = Args.extract_scale_box opts, deck
          trans = Args.extract_transform opts, deck
          ifile = Args.extract_input_file opts, deck
          deck.progress_bar.start('Loading PNG(s)', range.size) do |bar|
            range.each do |i|
              deck.cards[i].png(ifile[i].file, box[i], paint[i], trans[i])
              bar.increment
            end
          end
        end

      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
squib-0.19.0 lib/squib/dsl/png.rb
squib-0.19.0b lib/squib/dsl/png.rb
squib-0.19.0a lib/squib/dsl/png.rb