Blame operations/common/dropshadow.c

Packit bc1512
/* This file is an image processing operation for GEGL
Packit bc1512
 *
Packit bc1512
 * GEGL is free software; you can redistribute it and/or
Packit bc1512
 * modify it under the terms of the GNU Lesser General Public
Packit bc1512
 * License as published by the Free Software Foundation; either
Packit bc1512
 * version 3 of the License, or (at your option) any later version.
Packit bc1512
 *
Packit bc1512
 * GEGL is distributed in the hope that it will be useful,
Packit bc1512
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit bc1512
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit bc1512
 * Lesser General Public License for more details.
Packit bc1512
 *
Packit bc1512
 * You should have received a copy of the GNU Lesser General Public
Packit bc1512
 * License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
Packit bc1512
 *
Packit bc1512
 * Copyright 2006, 2010 Øyvind Kolås <pippin@gimp.org>
Packit bc1512
 */
Packit bc1512
Packit bc1512
#include "config.h"
Packit bc1512
#include <glib/gi18n-lib.h>
Packit bc1512
Packit bc1512
Packit bc1512
#ifdef GEGL_CHANT_PROPERTIES
Packit bc1512
Packit bc1512
gegl_chant_double (opacity, _("Opacity"), -2.0, 2.0, 0.5, _("Opacity"))
Packit bc1512
gegl_chant_double_ui (x, _("X"), -G_MAXDOUBLE, G_MAXDOUBLE, 20.0, -20.0, 20.0, 1.0,
Packit bc1512
                   _("Horizontal shadow offset"))
Packit bc1512
gegl_chant_double_ui (y, _("Y"), -G_MAXDOUBLE, G_MAXDOUBLE, 20.0, -20.0, 20.0, 1.0,
Packit bc1512
                   _("Vertical shadow offset"))
Packit bc1512
gegl_chant_double_ui (radius, _("Radius"), 0.0, G_MAXDOUBLE, 10.0, 0.0, 300.0, 1.5,
Packit bc1512
                   _("Blur radius"))
Packit bc1512
Packit bc1512
#else
Packit bc1512
Packit bc1512
#define GEGL_CHANT_TYPE_META
Packit bc1512
#define GEGL_CHANT_C_FILE       "dropshadow.c"
Packit bc1512
Packit bc1512
#include "gegl-chant.h"
Packit bc1512
Packit bc1512
/* in attach we hook into graph adding the needed nodes */
Packit bc1512
static void attach (GeglOperation *operation)
Packit bc1512
{
Packit bc1512
  GeglNode *gegl  = operation->node;
Packit bc1512
  GeglNode *input, *output, *over, *translate, *opacity, *blur, *darken, *black;
Packit bc1512
  GeglColor *black_color = gegl_color_new ("rgb(0.0,0.0,0.0)");
Packit bc1512
Packit bc1512
  input     = gegl_node_get_input_proxy (gegl, "input");
Packit bc1512
  output    = gegl_node_get_output_proxy (gegl, "output");
Packit bc1512
  over      = gegl_node_new_child (gegl, "operation", "gegl:over", NULL);
Packit bc1512
  translate = gegl_node_new_child (gegl, "operation", "gegl:translate", NULL);
Packit bc1512
  opacity   = gegl_node_new_child (gegl, "operation", "gegl:opacity", NULL);
Packit bc1512
  blur      = gegl_node_new_child (gegl, "operation", "gegl:gaussian-blur", NULL);
Packit bc1512
  darken    = gegl_node_new_child (gegl, "operation", "gegl:src-in", NULL);
Packit bc1512
  black     = gegl_node_new_child (gegl, "operation", "gegl:color",
Packit bc1512
                                     "value", black_color,
Packit bc1512
                                     NULL);
Packit bc1512
  g_object_unref (black_color);
Packit bc1512
Packit bc1512
  gegl_node_link_many (input, darken, blur, opacity, translate, over, output, NULL);
Packit bc1512
  gegl_node_connect_from (over, "aux", input, "output");
Packit bc1512
  gegl_node_connect_from (darken, "aux", black, "output");
Packit bc1512
Packit bc1512
  gegl_operation_meta_redirect (operation, "opacity", opacity, "value");
Packit bc1512
  gegl_operation_meta_redirect (operation, "radius", blur, "std-dev-x");
Packit bc1512
  gegl_operation_meta_redirect (operation, "radius", blur, "std-dev-y");
Packit bc1512
  gegl_operation_meta_redirect (operation, "x", translate, "x");
Packit bc1512
  gegl_operation_meta_redirect (operation, "y", translate, "y");
Packit bc1512
}
Packit bc1512
Packit bc1512
static void
Packit bc1512
gegl_chant_class_init (GeglChantClass *klass)
Packit bc1512
{
Packit bc1512
  GeglOperationClass *operation_class;
Packit bc1512
Packit bc1512
  operation_class = GEGL_OPERATION_CLASS (klass);
Packit bc1512
  operation_class->attach = attach;
Packit bc1512
Packit bc1512
  gegl_operation_class_set_keys (operation_class,
Packit bc1512
    "name"       , "gegl:dropshadow",
Packit bc1512
    "categories" , "meta:effects",
Packit bc1512
    "description",
Packit bc1512
    _("Creates a dropshadow effect on the input buffer"),
Packit bc1512
    NULL);
Packit bc1512
}
Packit bc1512
Packit bc1512
#endif