Sha256: c32ad456775f1d072907e59219b8104a719c081e93b0c80b844ba76949568bb7

Contents?: true

Size: 815 Bytes

Versions: 3

Compression:

Stored size: 815 Bytes

Contents

require 'cairo'
require_relative 'arg_loader'
require_relative 'color_validator'

module Squib::Args
  module_function def extract_paint(opts, deck)
    Paint.new(deck.custom_colors).extract!(opts, deck)
  end
  
  class Paint
    include ArgLoader
    include ColorValidator

    def initialize(custom_colors)
      @custom_colors = custom_colors
    end

    def self.parameters
      { alpha: 1.0,
        blend: :none,
        mask:  nil,
      }
    end

    def self.expanding_parameters
      parameters.keys # all of them are expandable
    end

    def self.params_with_units
      []
    end

    def validate_alpha(arg, _i)
      raise 'alpha must respond to to_f' unless arg.respond_to? :to_f
      arg.to_f
    end

    def validate_mask(arg, _i)
      colorify(arg, @custom_colors)
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
squib-0.19.0 lib/squib/args/paint.rb
squib-0.19.0b lib/squib/args/paint.rb
squib-0.19.0a lib/squib/args/paint.rb