Custom colors, closing #1
This commit is contained in:
@@ -46,7 +46,8 @@ module Squib
|
||||
CONFIG_DEFAULTS = {
|
||||
'dpi' => 300,
|
||||
'progress_bar' => false,
|
||||
'hint' => nil
|
||||
'hint' => nil,
|
||||
'custom_colors' => {}
|
||||
}
|
||||
|
||||
end
|
||||
@@ -52,6 +52,7 @@ module Squib
|
||||
@dpi = dpi
|
||||
@font = Squib::SYSTEM_DEFAULTS[:default_font]
|
||||
@cards = []
|
||||
@custom_colors = {}
|
||||
@progress_bar = Squib::Progress.new(false)
|
||||
cards.times{ @cards << Squib::Card.new(self, width, height) }
|
||||
load_config(config)
|
||||
@@ -88,6 +89,7 @@ module Squib
|
||||
@dpi = config['dpi'].to_i
|
||||
@text_hint = config['text_hint']
|
||||
@progress_bar.enabled = config['progress_bars']
|
||||
@custom_colors = config['custom_colors']
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -97,11 +97,11 @@ module Squib
|
||||
# :nodoc:
|
||||
# @api private
|
||||
def colorify(opts, nillable=false)
|
||||
if nillable # for optional color arguments like text hints
|
||||
opts[:color] = Cairo::Color.parse(opts[:color]) unless opts[:color].nil?
|
||||
else
|
||||
opts[:color] = Cairo::Color.parse(opts[:color])
|
||||
return opts if nillable && opts[:color].nil?
|
||||
if @custom_colors.key? opts[:color].to_s
|
||||
opts[:color] = @custom_colors[opts[:color].to_s]
|
||||
end
|
||||
opts[:color] = Cairo::Color.parse(opts[:color])
|
||||
opts
|
||||
end
|
||||
module_function :colorify
|
||||
|
||||
@@ -10,3 +10,7 @@
|
||||
|
||||
# Show progress bars on the command line for potentially long-running operations
|
||||
#progress_bars: true
|
||||
|
||||
#Enable some custom colors that can be used in any color
|
||||
#custom_colors:
|
||||
# foo: '#abc'
|
||||
Reference in New Issue
Block a user