Putting together a global set method for defaults
This commit is contained in:
@@ -6,12 +6,28 @@ module Squib
|
||||
# Setting a hint to nil or to :off will disable hints. @see samples/text.rb
|
||||
#
|
||||
# @param [Color] text the color of the text hint. To turn off use nil or :off. @see API.md
|
||||
# @return nil
|
||||
# @return [nil] Returns nothing
|
||||
# @api public
|
||||
def hint(text: nil)
|
||||
text = nil if text == :off
|
||||
@text_hint = text
|
||||
end
|
||||
|
||||
# Sets various defaults for this deck. Defaults can be overriden by the commands themselves
|
||||
# @example
|
||||
# set font: 'Arial 26'
|
||||
# text 'blah' # in Arial 26
|
||||
# text 'blah24', font: 'Arial 24' # in Arial 24
|
||||
# set font: :default # Back to Squib-wide default
|
||||
#
|
||||
# @param opts: the hash of options.
|
||||
# @option font: the font string to set as default. Can also be set to `:default` to use the Squib-wide default.
|
||||
# @return [nil] Returns nothing
|
||||
# @api public
|
||||
def set(opts = {})
|
||||
opts = needs(opts, [:font])
|
||||
@font = opts[:font]
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,16 +1,6 @@
|
||||
module Squib
|
||||
class Deck
|
||||
|
||||
# @api private todo
|
||||
def font(type: 'Arial', size: 12, **options)
|
||||
raise 'Not implemented!'
|
||||
end
|
||||
|
||||
# @api private todo
|
||||
def set_font(type: 'Arial', size: 12, **options)
|
||||
raise 'Not implemented!'
|
||||
end
|
||||
|
||||
# Renders a string at a given location, width, alignment, font, etc.
|
||||
# Unix-like newlines are interpreted even on Windows.
|
||||
#
|
||||
|
||||
@@ -8,7 +8,7 @@ module Squib
|
||||
:fill_color => '#0000',
|
||||
:stroke_color => :black,
|
||||
:stroke_width => 2.0,
|
||||
:font => 'Arial, Sans 36',
|
||||
:font => :use_set,
|
||||
:sheet => 0,
|
||||
:x => 0,
|
||||
:y => 0,
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ module Squib
|
||||
def initialize(width: 825, height: 1125, cards: 1, dpi: 300, config: 'config.yml', &block)
|
||||
@width=width; @height=height
|
||||
@dpi = dpi
|
||||
@font = 'Sans 36'
|
||||
@font = Squib::SYSTEM_DEFAULTS[:font]
|
||||
@cards = []
|
||||
cards.times{ @cards << Squib::Card.new(self, width, height) }
|
||||
load_config(config)
|
||||
|
||||
Reference in New Issue
Block a user