[cairo-commit] rcairo/src/lib/cairo color.rb,1.5,1.6

Kouhei Sutou commit at pdx.freedesktop.org
Wed Apr 18 04:57:53 PDT 2007


Committed by: kou

Update of /cvs/cairo/rcairo/src/lib/cairo
In directory kemper:/tmp/cvs-serv27713/src/lib/cairo

Modified Files:
	color.rb 
Log Message:
* src/lib/cairo/color.rb (Cairo::Color.parse):
  - supported :hsv and :hsva.
  - added robust parse mode.


Index: color.rb
===================================================================
RCS file: /cvs/cairo/rcairo/src/lib/cairo/color.rb,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- color.rb	18 Apr 2007 11:46:36 -0000	1.5
+++ color.rb	18 Apr 2007 11:57:43 -0000	1.6
@@ -1,13 +1,15 @@
 module Cairo
   module Color
     module_function
-    def parse(value)
+    def parse(value, robust=false)
       return value.dup if value.is_a?(Base)
       case value
       when Array
         case value.first
         when :cmyk, :cmyka
           CMYK.new(*value[1..-1])
+        when :hsv, :hsva
+          HSV.new(*value[1..-1])
         else
           type, *value = value if [:rgb, :rgba].include?(value.first)
           RGB.new(*value)
@@ -22,7 +24,9 @@
           raise ArgumentError, "unknown color name: #{value}"
         end
       else
-        # can't parse. should raise?
+        if robust
+          raise ArgumentError, "can't parse as color name: #{value.inspect}"
+        end
         value
       end
     end



More information about the cairo-commit mailing list