[gegl] operations: clean up dropshadow and add a "color" property



commit 32e68d87bc8ca84d4069aea366ebac67b6de366b
Author: Michael Natterer <mitch gimp org>
Date:   Sat Jun 1 00:32:53 2013 +0200

    operations: clean up dropshadow and add a "color" property

 operations/common/dropshadow.c |   60 +++++++++++++++++++++++++--------------
 1 files changed, 38 insertions(+), 22 deletions(-)
---
diff --git a/operations/common/dropshadow.c b/operations/common/dropshadow.c
index 321ba2b..f687022 100644
--- a/operations/common/dropshadow.c
+++ b/operations/common/dropshadow.c
@@ -22,27 +22,42 @@
 
 #ifdef GEGL_CHANT_PROPERTIES
 
-/* It does make sense to sometimes have opacities > 1 (see GEGL logo for example) */
-gegl_chant_double (opacity, _("Opacity"), 0.0, 2.0, 0.5, _("Opacity"))
-gegl_chant_double_ui (x, _("X"), -G_MAXDOUBLE, G_MAXDOUBLE, 20.0, -20.0, 20.0, 1.0,
-                   _("Horizontal shadow offset"))
-gegl_chant_double_ui (y, _("Y"), -G_MAXDOUBLE, G_MAXDOUBLE, 20.0, -20.0, 20.0, 1.0,
-                   _("Vertical shadow offset"))
-gegl_chant_double_ui (radius, _("Radius"), 0.0, G_MAXDOUBLE, 10.0, 0.0, 300.0, 1.5,
-                   _("Blur radius"))
+gegl_chant_double_ui (x, _("X"),
+                      -G_MAXDOUBLE, G_MAXDOUBLE, 20.0, -20.0, 20.0, 1.0,
+                      _("Horizontal shadow offset"))
+
+gegl_chant_double_ui (y, _("Y"),
+                      -G_MAXDOUBLE, G_MAXDOUBLE, 20.0, -20.0, 20.0, 1.0,
+                      _("Vertical shadow offset"))
+
+gegl_chant_double_ui (radius, _("Radius"),
+                      0.0, G_MAXDOUBLE, 10.0, 0.0, 300.0, 1.5,
+                      _("Blur radius"))
+
+gegl_chant_color     (color, _("Color"),
+                      "black",
+                      _("The shadow's color (defaults to 'black')"))
+
+/* It does make sense to sometimes have opacities > 1 (see GEGL logo
+ * for example)
+ */
+gegl_chant_double    (opacity, _("Opacity"),
+                      0.0, 2.0, 0.5,
+                      _("Opacity"))
 
 #else
 
 #define GEGL_CHANT_TYPE_META
-#define GEGL_CHANT_C_FILE       "dropshadow.c"
+#define GEGL_CHANT_C_FILE "dropshadow.c"
 
 #include "gegl-chant.h"
 
 /* in attach we hook into graph adding the needed nodes */
-static void attach (GeglOperation *operation)
+static void
+attach (GeglOperation *operation)
 {
-  GeglNode *gegl  = operation->node;
-  GeglNode *input, *output, *over, *translate, *opacity, *blur, *darken, *black;
+  GeglNode  *gegl = operation->node;
+  GeglNode  *input, *output, *over, *translate, *opacity, *blur, *darken, *black;
   GeglColor *black_color = gegl_color_new ("rgb(0.0,0.0,0.0)");
 
   input     = gegl_node_get_input_proxy (gegl, "input");
@@ -52,33 +67,34 @@ static void attach (GeglOperation *operation)
   opacity   = gegl_node_new_child (gegl, "operation", "gegl:opacity", NULL);
   blur      = gegl_node_new_child (gegl, "operation", "gegl:gaussian-blur", NULL);
   darken    = gegl_node_new_child (gegl, "operation", "gegl:src-in", NULL);
-  black     = gegl_node_new_child (gegl, "operation", "gegl:color",
-                                     "value", black_color,
-                                     NULL);
+  color     = gegl_node_new_child (gegl, "operation", "gegl:color",
+                                   "value", black_color,
+                                   NULL);
   g_object_unref (black_color);
 
-  gegl_node_link_many (input, darken, blur, opacity, translate, over, output, NULL);
+  gegl_node_link_many (input, darken, blur, opacity, translate, over, output,
+                       NULL);
   gegl_node_connect_from (over, "aux", input, "output");
-  gegl_node_connect_from (darken, "aux", black, "output");
+  gegl_node_connect_from (darken, "aux", color, "output");
 
-  gegl_operation_meta_redirect (operation, "opacity", opacity, "value");
   gegl_operation_meta_redirect (operation, "radius", blur, "std-dev-x");
   gegl_operation_meta_redirect (operation, "radius", blur, "std-dev-y");
   gegl_operation_meta_redirect (operation, "x", translate, "x");
   gegl_operation_meta_redirect (operation, "y", translate, "y");
+  gegl_operation_meta_redirect (operation, "color", color, "value");
+  gegl_operation_meta_redirect (operation, "opacity", opacity, "value");
 }
 
 static void
 gegl_chant_class_init (GeglChantClass *klass)
 {
-  GeglOperationClass *operation_class;
+  GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
 
-  operation_class = GEGL_OPERATION_CLASS (klass);
   operation_class->attach = attach;
 
   gegl_operation_class_set_keys (operation_class,
-    "name"       , "gegl:dropshadow",
-    "categories" , "meta:effects",
+    "name",        "gegl:dropshadow",
+    "categories",  "meta:effects",
     "description",
     _("Creates a dropshadow effect on the input buffer"),
     NULL);


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