class Squib::TextEmbed
Attributes
deck[R]
dsl_method[R]
rules[R]
Public Class Methods
accepted_params()
click to toggle source
# File lib/squib/dsl/text_embed.rb, line 20 def self.accepted_params %i( key file id force_id layout width height dx dy id force_id data flip_horizontal flip_vertical alpha angle blend mask placeholder ) end
new(deck, dsl_method)
click to toggle source
# File lib/squib/dsl/text_embed.rb, line 15 def initialize(deck, dsl_method) @deck = deck @rules = {} # store an array of options for later usage end
Public Instance Methods
png(opts = {})
click to toggle source
# File lib/squib/dsl/text_embed.rb, line 55 def png(opts = {}) warn_if_unexpected opts key = Args::EmbedKey.new.validate_key(opts[:key]) range = Args.extract_range opts, deck paint = Args.extract_paint opts, deck box = Args.extract_box opts, deck, { width: :native, height: :native } adjust = Args::EmbedAdjust.new.load!(opts, expand_by: deck.size, layout: deck.layout, dpi: deck.dpi) trans = Args.extract_transform opts, deck ifile = Args.extract_input_file opts, deck rule = { type: :png, file: ifile, box: box, paint: paint, trans: trans, adjust: adjust } rule[:draw] = Proc.new do |card, x, y, scale| i = card.index b = box[i] b.x, b.y = x, y b.width = b.width * scale if b.width.is_a? Numeric b.height = b.height * scale if b.height.is_a? Numeric Dir.chdir(deck.img_dir) do card.png(ifile[i].file, b, paint[i], trans[i]) end end @rules[key] = rule end
svg(opts = {})
click to toggle source
# File lib/squib/dsl/text_embed.rb, line 30 def svg(opts = {}) warn_if_unexpected opts key = Args::EmbedKey.new.validate_key(opts[:key]) range = Args.extract_range opts, deck paint = Args.extract_paint opts, deck box = Args.extract_box opts, deck, { width: :native, height: :native } adjust = Args::EmbedAdjust.new.load!(opts, expand_by: deck.size, layout: deck.layout, dpi: deck.dpi) trans = Args.extract_transform opts, deck ifile = Args.extract_input_file opts, deck svg_args = Args.extract_svg_special opts, deck rule = { type: :svg, file: ifile, box: box, paint: paint, trans: trans, adjust: adjust, svg_args: svg_args } rule[:draw] = Proc.new do |card, x, y, scale| i = card.index b = box[i] b.x, b.y = x, y b.width = b.width * scale if b.width.is_a? Numeric b.height = b.height * scale if b.height.is_a? Numeric Dir.chdir(deck.img_dir) do card.svg(ifile[i].file, svg_args[i], b, paint[i], trans[i]) end end @rules[key] = rule end