From 33d9c3f908eadf5ba12999d14e0f970480d873e9 Mon Sep 17 00:00:00 2001 From: LinuxBeaver <78667207+LinuxBeaver@users.noreply.github.com> Date: Sun, 7 May 2023 15:25:41 -0400 Subject: [PATCH] Update bevel.c --- GEGL_EFFECTS/compile_bevel_here/bevel.c | 97 +++++++++++++++++++++---- 1 file changed, 83 insertions(+), 14 deletions(-) diff --git a/GEGL_EFFECTS/compile_bevel_here/bevel.c b/GEGL_EFFECTS/compile_bevel_here/bevel.c index ca9b792..d2e9b62 100644 --- a/GEGL_EFFECTS/compile_bevel_here/bevel.c +++ b/GEGL_EFFECTS/compile_bevel_here/bevel.c @@ -14,6 +14,7 @@ * License along with GEGL; if not, see . * * Copyright 2006 Øyvind Kolås + * 2022 Beaver (GEGL Bevel) */ #include "config.h" @@ -21,13 +22,30 @@ #ifdef GEGL_PROPERTIES +property_boolean (effectsswitchbevel, _("Enable Bevel (FOR GEGL EFFECTS ONLY)"), TRUE) + description (_("This switch exist for GEGL Effects testing. You won't find it in stand alone bevel'")) + ui_meta ("role", "output-extent") +property_boolean (embossmode, _("Emboss Mode (use Gimp's layer Grain Merge blend mode)"), FALSE) + description (_("Make an embossed bevel'")) -property_double (radius1, _("Radius"), 7.0) + + + + + + + +property_double (radius1, _("Radius Normal Bevel"), 7.0) value_range (1.0, 40.0) ui_range (1.0, 12) ui_gamma (1.5) +property_int (radius2, _("Radius Sharp Bevel"), 0) + description(_("Box Blur -0 means disabled by default")) + value_range (0, 8) + ui_range (0, 8) + ui_gamma (1.5) property_double (bevel1, _("Depth Angle"), 90.0) @@ -59,10 +77,23 @@ property_double (azimuth, _("Rotate Lighting"), 40.0) #include "gegl-op.h" + +typedef struct +{ + GeglNode *input; + GeglNode *blur; + GeglNode *boxblur; + GeglNode *emb; + GeglNode *th; + GeglNode *output; +} State; + + static void attach (GeglOperation *operation) { GeglNode *gegl = operation->node; - GeglNode *input, *output, *blur, *emb, *th; + GeglProperties *o = GEGL_PROPERTIES (operation); + GeglNode *input, *output, *boxblur, *blur, *emb, *th; input = gegl_node_get_input_proxy (gegl, "input"); output = gegl_node_get_output_proxy (gegl, "output"); @@ -71,6 +102,12 @@ static void attach (GeglOperation *operation) "operation", "gegl:gaussian-blur", NULL); + boxblur = gegl_node_new_child (gegl, + "operation", "gegl:box-blur", + NULL); + + + emb = gegl_node_new_child (gegl, "operation", "gegl:emboss", @@ -82,40 +119,72 @@ static void attach (GeglOperation *operation) - gegl_node_link_many (input, blur, emb, th, output, NULL); - + gegl_node_link_many (input, blur, boxblur, emb, th, output, NULL); gegl_operation_meta_redirect (operation, "radius1", blur, "std-dev-x"); gegl_operation_meta_redirect (operation, "radius1", blur, "std-dev-y"); - - gegl_operation_meta_redirect (operation, "bevelhidden", emb, ""); - gegl_operation_meta_redirect (operation, "bevel1", emb, "elevation"); - gegl_operation_meta_redirect (operation, "bevel2", emb, "depth"); - gegl_operation_meta_redirect (operation, "azimuth", emb, "azimuth"); + gegl_operation_meta_redirect (operation, "radius2", boxblur, "radius"); + gegl_operation_meta_redirect (operation, "th", th, "value"); - gegl_operation_meta_redirect (operation, "th", th, "value"); + /* Now save points to the various gegl nodes so we can rewire them in + * update_graph() later + */ + State *state = g_malloc0 (sizeof (State)); + state->input = input; + state->blur = blur; + state->boxblur = boxblur; + state->emb = emb; + state->th = th; + state->output = output; + o->user_data = state; } static void -gegl_op_class_init (GeglOpClass *klass) +update_graph (GeglOperation *operation) { - GeglOperationClass *operation_class; + GeglProperties *o = GEGL_PROPERTIES (operation); + State *state = o->user_data; + if (!state) return; + + if (o->effectsswitchbevel) + if (o->embossmode) + { + gegl_node_link_many (state->blur, state->boxblur, state->emb, state->output, NULL); + } +else + { + gegl_node_link_many (state->blur, state->boxblur, state->emb, state->th, state->output, NULL); + } +else + { + gegl_node_link_many (state->input, state->output, NULL); + } +} - operation_class = GEGL_OPERATION_CLASS (klass); + + + + +static void +gegl_op_class_init (GeglOpClass *klass) +{ + GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass); + GeglOperationMetaClass *operation_meta_class = GEGL_OPERATION_META_CLASS (klass); operation_class->attach = attach; + operation_meta_class->update = update_graph; gegl_operation_class_set_keys (operation_class, "name", "gegl:bevel", "title", _("Bevel"), "categories", "Aristic", "reference-hash", "45ed5656a28a512570f0f25sb2ac", - "description", _("Bevel Images using GEGL. Use the multiply blend mode " + "description", _("You are expected to use GEGL or Gimp blend modes with this plugin. Works best with blend modes multiply and grain merge. Emboss mode requires non-GEGL Gimp blend modes" ""), NULL); }