Blame operations/common/dropshadow.c

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