Custom colors, closing #1

This commit is contained in:
Andy Meneely
2014-08-05 21:56:07 -04:00
parent 96d8f4039e
commit 6c31320411
8 changed files with 50 additions and 8 deletions
+2 -1
View File
@@ -46,7 +46,8 @@ module Squib
CONFIG_DEFAULTS = {
'dpi' => 300,
'progress_bar' => false,
'hint' => nil
'hint' => nil,
'custom_colors' => {}
}
end
+2
View File
@@ -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
+4 -4
View File
@@ -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
+4
View File
@@ -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'