Module: EideticRML::Styles::HasColor
- Included in:
- BrushStyle, FontStyle, PenStyle, TextStyle
- Defined in:
- lib/erml_styles.rb
Instance Method Summary collapse
Instance Method Details
#color(value = nil) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/erml_styles.rb', line 12 def color(value=nil) return @color || 0 if value.nil? @color = case value when /^#([0-9A-Fa-f]{6})$/ # 6-digit hex color $1.to_i(16) when /^#([0-9A-Fa-f]{3})$/ # 3-digit hex color $1.gsub(/(\w)/, '\\1\\1').to_i(16) else value end end |