[gegl] Allow integers for rgb(a) property values



commit a58ed8d9c872ce5f10a6406ffd248a90f502752a
Author: Danny Robson <danny blubinc net>
Date:   Tue May 25 16:17:47 2010 +1000

    Allow integers for rgb(a) property values

 gegl/property-types/gegl-color.c             |   18 ++++++++---
 tests/compositions/reference/rgb-params.gegl |  Bin 0 -> 131368 bytes
 tests/compositions/rgb-params.xml            |   41 ++++++++++++++++++++++++++
 3 files changed, 54 insertions(+), 5 deletions(-)
---
diff --git a/gegl/property-types/gegl-color.c b/gegl/property-types/gegl-color.c
index 40eddab..6debe23 100644
--- a/gegl/property-types/gegl-color.c
+++ b/gegl/property-types/gegl-color.c
@@ -141,14 +141,22 @@ parse_float_argument_list (GeglColor *color,
    */
   for (i = 0; i < num_arguments; ++i)
     {
-      if (g_scanner_get_next_token (scanner) != G_TOKEN_FLOAT)
+      switch (g_scanner_get_next_token (scanner))
         {
-          return FALSE;
+          case G_TOKEN_FLOAT:
+            token_value = g_scanner_cur_value (scanner);
+            color->priv->rgba_color[i] = token_value.v_float;
+            break;
+
+          case G_TOKEN_INT:
+            token_value = g_scanner_cur_value (scanner);
+            color->priv->rgba_color[i] = token_value.v_int64;
+            break;
+
+          default:
+            return FALSE;
         }
 
-      token_value         = g_scanner_cur_value (scanner);
-      color->priv->rgba_color[i] = token_value.v_float;
-
       /* Verify that there is a ',' after each float, except the last one */
       if (i < (num_arguments - 1))
         {
diff --git a/tests/compositions/reference/rgb-params.gegl b/tests/compositions/reference/rgb-params.gegl
new file mode 100644
index 0000000..1db69be
Binary files /dev/null and b/tests/compositions/reference/rgb-params.gegl differ
diff --git a/tests/compositions/rgb-params.xml b/tests/compositions/rgb-params.xml
new file mode 100644
index 0000000..13bb53c
--- /dev/null
+++ b/tests/compositions/rgb-params.xml
@@ -0,0 +1,41 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Ensure that rgb parameters can be specified using floating point and
+     integer values. Integer values are primarily useful for specifying
+     0, 1, or working with HDR.
+
+     Visually, this should appear as cyan square of one tone: right is
+     integer, left is floating point.
+-->
+<gegl>
+  <node operation='gegl:over'>
+      <node operation='gegl:translate'>
+          <params>
+            <param name='x'>5.000000</param>
+            <param name='y'>0.000000</param>
+          </params>
+      </node>
+      <node operation='gegl:crop'>
+        <params>
+          <param name='width'>5.000000</param>
+          <param name='height'>10.000000</param>
+        </params>
+      </node>
+      <node operation='gegl:color'>
+        <params>
+          <param name='value'>rgb(0, 5, 1)</param>
+        </params>
+      </node>
+  </node>
+  <node operation='gegl:crop'>
+    <params>
+      <param name='width'>10.000000</param>
+      <param name='height'>10.000000</param>
+    </params>
+  </node>
+  <node operation='gegl:color'>
+    <params>
+      <param name='value'>rgb(0.0, 5.0, 1.0)</param>
+    </params>
+  </node>
+</gegl>
+



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]