Implementing an img_dir configuration setting
This commit is contained in:
+14
-10
@@ -19,10 +19,12 @@ module Squib
|
||||
# @api public
|
||||
def png(opts = {})
|
||||
opts = needs(opts, [:range, :files, :x, :y, :alpha, :layout, :blend])
|
||||
@progress_bar.start("Loading PNG(s)", opts[:range].size) do |bar|
|
||||
opts[:range].each do |i|
|
||||
@cards[i].png(opts[:file][i], opts[:x][i], opts[:y][i], opts[:alpha][i], opts[:blend][i])
|
||||
bar.increment
|
||||
Dir.chdir(@img_dir) do
|
||||
@progress_bar.start("Loading PNG(s)", opts[:range].size) do |bar|
|
||||
opts[:range].each do |i|
|
||||
@cards[i].png(opts[:file][i], opts[:x][i], opts[:y][i], opts[:alpha][i], opts[:blend][i])
|
||||
bar.increment
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -48,13 +50,15 @@ module Squib
|
||||
# @api public
|
||||
def svg(opts = {})
|
||||
p = needs(opts,[:range, :files, :svgid, :force_svgid, :x, :y, :width, :height, :layout, :alpha, :blend])
|
||||
@progress_bar.start("Loading SVG(s)", p[:range].size) do |bar|
|
||||
p[:range].each do |i|
|
||||
unless p[:force_id][i] && p[:id][i].to_s.empty?
|
||||
@cards[i].svg(p[:file][i], p[:id][i], p[:x][i], p[:y][i],
|
||||
p[:width][i], p[:height][i], p[:alpha][i], p[:blend][i])
|
||||
Dir.chdir(@img_dir) do
|
||||
@progress_bar.start("Loading SVG(s)", p[:range].size) do |bar|
|
||||
p[:range].each do |i|
|
||||
unless p[:force_id][i] && p[:id][i].to_s.empty?
|
||||
@cards[i].svg(p[:file][i], p[:id][i], p[:x][i], p[:y][i],
|
||||
p[:width][i], p[:height][i], p[:alpha][i], p[:blend][i])
|
||||
end
|
||||
bar.increment
|
||||
end
|
||||
bar.increment
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -17,7 +17,7 @@ module Squib
|
||||
@text_hint = text
|
||||
end
|
||||
|
||||
# Sets various defaults for this deck. Defaults can be overriden by the commands themselves
|
||||
# Sets various defaults for this deck. Defaults can be overriden by the commands themselves when that command supports it.
|
||||
# @example
|
||||
# set font: 'Arial 26'
|
||||
# text 'blah' # in Arial 26
|
||||
@@ -25,11 +25,13 @@ module Squib
|
||||
# set font: :default # Back to Squib-wide default
|
||||
#
|
||||
# @option opts font: the font string to set as default. Can also be set to `:default` to use the Squib-wide default.
|
||||
# @option opts img_dir: the default directory to READ images from. Default is `.`. Useful for switching from bw to color images.
|
||||
# @return [nil] Returns nothing
|
||||
# @api public
|
||||
def set(opts = {})
|
||||
opts = needs(opts, [:font])
|
||||
opts = needs(opts, [:font, :img_dir])
|
||||
@font = opts[:font][0] #was expanded - just need the first
|
||||
@img_dir = opts[:img_dir]
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user