def self.build(ground, values)
unless [1, 3].include?(values.size)
raise ArgumentError,
"Wrong number of arguments for color definition, should be 1 or 3"
end
color = values.size == 1 ? values.first : values
case color
when 0.class
Indexed.new(ground, color)
when Symbol
if Named.color_names.include?(color)
Named.new(ground, color)
elsif X11Named.color_names.include?(color)
X11Named.new(ground, color)
else
raise ArgumentError,
"Unknown color name, valid names: " +
(Named.color_names + X11Named.color_names).join(', ')
end
when Array
RGB.new(ground, *color)
when String
RGB.new(ground, *parse_hex_color(color))
end
end