30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# 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. opts, deck
paint = Args. opts, deck
box = Args. opts, deck, { width: :native, height: :native }
adjust = Args::EmbedAdjust.new.load!(opts, expand_by: deck.size, layout: deck.layout, dpi: deck.dpi)
trans = Args. opts, deck
ifile = Args. opts, deck
svg_args = Args. 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
|