Module: Rszr::Color
- Defined in:
- lib/rszr/color.rb,
lib/rszr/color/base.rb,
lib/rszr/color/cmya.rb,
lib/rszr/color/rgba.rb,
lib/rszr/color/point.rb,
lib/rszr/color/gradient.rb
Defined Under Namespace
Classes: Base, CMYA, Gradient, Point, RGBA
Constant Summary collapse
Class Method Summary collapse
Class Method Details
.hex(str) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/rszr/color/rgba.rb', line 9 def hex(str) str = str[1..-1] if str.start_with?('#') case str.size when 3, 4 then hex(str.chars.map { |c| c * 2 }.join) when 6 then hex("#{str}ff") when 8 rgba(*str.scan(/../).map(&:hex)) else raise ArgumentError, 'invalid color code' end end |