More work on the conversion

This commit is contained in:
Andy Meneely
2014-07-25 17:38:23 -04:00
parent 246b9df9fc
commit 093b2cf15b
8 changed files with 46 additions and 29 deletions
+9 -7
View File
@@ -7,10 +7,10 @@ module Squib
# @param dir: the directory for the output to be sent to. Will be created if it doesn't exist
# @param format: the format that this will be rendered too. Options `:pdf, :png`. Array of both is allowed: `[:pdf, :png]`
# @param prefix: the prefix of the file name to be printed
def save(range: :all, dir: "_output", format: :png, prefix: "card_")
format = [format].flatten
save_png(range: range, dir: dir, prefix: prefix) if format.include? :png
save_pdf if format.include? :pdf
def save(opts = {})
opts = needs(opts, [:range, :creatable_dir, :formats, :prefix])
save_png(opts) if opts[:format].include? :png
save_pdf(opts) if opts[:format].include? :pdf
end
# Saves the range of cards to PNG
@@ -18,9 +18,11 @@ module Squib
# @param range: the range of cards over which this will be rendered. See {file:API.md#label-Specifying+Ranges Specifying Ranges}
# @param dir: the directory for the output to be sent to. Will be created if it doesn't exist
# @param prefix: the prefix of the file name to be printed
def save_png(range: :all, dir: "_output", prefix: 'card_')
range = rangeify(range); dir = dirify(dir, allow_create: true)
range.each { |i| @cards[i].save_png(i, dir, prefix) }
def save_png(opts = {})
opts = needs(opts,[:range, :creatable_dir, :prefix])
opts[:range].each do |i|
@cards[i].save_png(i, opts[:dir], opts[:prefix])
end
end
end
+1 -1
View File
@@ -10,7 +10,7 @@ module Squib
# @api public
def hint(text: nil)
text = nil if text == :off
@text_hint = colorify(text, nillable: true)
@text_hint = text
end
end
+7 -8
View File
@@ -14,14 +14,13 @@ module Squib
# @param stroke_color: the color with which to stroke the outside of the rectangle
# @param stroke_width: the width of the outside stroke
# @api public
def rect(range: :all, x: 0, y: 0, width: 825, height: 1125, \
radius: nil, x_radius: 0, y_radius: 0, \
fill_color: '#0000', stroke_color: :black, stroke_width: 2.0)
range = rangeify(range)
color = colorify(color)
x_radius,y_radius = radiusify(radius, x_radius, y_radius)
range.each do |i|
@cards[i].draw_rectangle(x, y, width, height, x_radius, y_radius, fill_color, stroke_color, stroke_width)
def rect(opts = {})
opts = needs(opts, [:range, :x, :y, :width, :height, :radius,
:fill_color, :stroke_color, :stroke_width])
opts[:range].each do |i|
@cards[i].rect(opts[:x], opts[:y], opts[:width], opts[:height],
opts[:x_radius], opts[:y_radius],
opts[:fill_color], opts[:stroke_color], opts[:stroke_width])
end
end
+6 -8
View File
@@ -40,14 +40,12 @@ module Squib
# @option hint: show a text hint with the given color. Overrides global hints (see {Deck#hint}).
# @return [nil] Returns nothing
# @api public
def text(range: :all, str: '', font: :use_set, x: 0, y: 0, **options)
range = rangeify(range)
str = [str] * @cards.size unless str.respond_to? :each
font = fontify(font)
color = colorify(options[:color], nillable: false)
options[:hint] = colorify(options[:hint]) unless options[:hint].nil?
range.each do |i|
cards[i].text(str[i], font, x, y, color, options)
def text(opts = {})
opts = needs(opts, [:range, :str, :font, :x, :y, :width, :height, :color, :wrap,
:fitxy, :align, :justify, :valign, :ellipsize, :hint])
str = [opts[:str]] * @cards.size unless str.respond_to? :each
opts[:range].each do |i|
@cards[i].text(str[i], opts[:font], opts[:x], opts[:y], opts[:color], opts) #TODO split this out
end
end