app, pdb, plug-ins: replace (plug-in-spread).

For plug-in writers reference, these are equivalent:

- (plug-in-spread RUN-NONINTERACTIVE image layer inSpread inSpread)
+ (gimp-drawable-merge-new-filter layer "gegl:noise-spread" 0 LAYER-MODE-REPLACE 1.0 "amount-x" inSpread "amount-y" inSpread "seed" (msrg-rand))
This commit is contained in:
Jehan 2024-12-15 17:18:23 +01:00
parent 5af02d292a
commit 3c0c4db614
6 changed files with 5 additions and 159 deletions

View file

@ -30,7 +30,7 @@
#include "internal-procs.h" #include "internal-procs.h"
/* 728 procedures registered total */ /* 727 procedures registered total */
void void
internal_procs_init (GimpPDB *pdb) internal_procs_init (GimpPDB *pdb)

View file

@ -916,50 +916,6 @@ plug_in_noisify_invoker (GimpProcedure *procedure,
error ? *error : NULL); error ? *error : NULL);
} }
static GimpValueArray *
plug_in_spread_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpDrawable *drawable;
gdouble spread_amount_x;
gdouble spread_amount_y;
drawable = g_value_get_object (gimp_value_array_index (args, 2));
spread_amount_x = g_value_get_double (gimp_value_array_index (args, 3));
spread_amount_y = g_value_get_double (gimp_value_array_index (args, 4));
if (success)
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GeglNode *node =
gegl_node_new_child (NULL,
"operation", "gegl:noise-spread",
"amount-x", (gint) spread_amount_x,
"amount-y", (gint) spread_amount_y,
"seed", g_random_int (),
NULL);
gimp_drawable_apply_operation (drawable, progress,
C_("undo-type", "Spread"),
node);
g_object_unref (node);
}
else
success = FALSE;
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GimpValueArray * static GimpValueArray *
plug_in_threshold_alpha_invoker (GimpProcedure *procedure, plug_in_threshold_alpha_invoker (GimpProcedure *procedure,
Gimp *gimp, Gimp *gimp,
@ -1597,54 +1553,6 @@ register_plug_in_compat_procs (GimpPDB *pdb)
gimp_pdb_register_procedure (pdb, procedure); gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure); g_object_unref (procedure);
/*
* gimp-plug-in-spread
*/
procedure = gimp_procedure_new (plug_in_spread_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"plug-in-spread");
gimp_procedure_set_static_help (procedure,
"Move pixels around randomly",
"Spreads the pixels of the specified drawable. Pixels are randomly moved to another location whose distance varies from the original by the horizontal and vertical spread amounts.",
NULL);
gimp_procedure_set_static_attribution (procedure,
"Compatibility procedure. Please see 'gegl:noise-spread' for credits.",
"Compatibility procedure. Please see 'gegl:noise-spread' for credits.",
"2013");
gimp_procedure_add_argument (procedure,
g_param_spec_enum ("run-mode",
"run mode",
"The run mode",
GIMP_TYPE_RUN_MODE,
GIMP_RUN_INTERACTIVE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_image ("image",
"image",
"Input image (unused)",
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable ("drawable",
"drawable",
"Input drawable",
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_double ("spread-amount-x",
"spread amount x",
"Horizontal spread amount",
0, 512, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_double ("spread-amount-y",
"spread amount y",
"Vertical spread amount",
0, 512, 0,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/* /*
* gimp-plug-in-threshold-alpha * gimp-plug-in-threshold-alpha
*/ */

View file

@ -575,58 +575,6 @@ CODE
); );
} }
sub plug_in_spread {
$blurb = 'Move pixels around randomly';
$help = <<'HELP';
Spreads the pixels of the specified drawable. Pixels are randomly
moved to another location whose distance varies from the original by
the horizontal and vertical spread amounts.
HELP
&std_pdb_compat('gegl:noise-spread');
$date = '2013';
@inargs = (
{ name => 'run_mode', type => 'enum GimpRunMode', dead => 1,
desc => 'The run mode' },
{ name => 'image', type => 'image', dead => 1,
desc => 'Input image (unused)' },
{ name => 'drawable', type => 'drawable',
desc => 'Input drawable' },
{ name => 'spread_amount_x', type => '0 <= double <= 512',
desc => 'Horizontal spread amount' },
{ name => 'spread_amount_y', type => '0 <= double <= 512',
desc => 'Vertical spread amount' }
);
%invoke = (
code => <<'CODE'
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GeglNode *node =
gegl_node_new_child (NULL,
"operation", "gegl:noise-spread",
"amount-x", (gint) spread_amount_x,
"amount-y", (gint) spread_amount_y,
"seed", g_random_int (),
NULL);
gimp_drawable_apply_operation (drawable, progress,
C_("undo-type", "Spread"),
node);
g_object_unref (node);
}
else
success = FALSE;
}
CODE
);
}
sub plug_in_threshold_alpha { sub plug_in_threshold_alpha {
$blurb = 'Make transparency all-or-nothing'; $blurb = 'Make transparency all-or-nothing';
@ -1144,7 +1092,6 @@ CODE
plug_in_plasma plug_in_plasma
plug_in_rotate plug_in_rotate
plug_in_noisify plug_in_noisify
plug_in_spread
plug_in_threshold_alpha plug_in_threshold_alpha
plug_in_waves); plug_in_waves);

View file

@ -58,9 +58,8 @@
blobSize blobSize) blobSize blobSize)
) )
; Clamp spread value to 'plug-in-spread' limits. ; Clamp spread value to 'gegl:noise-spread' limits.
; This plugin calls plug-in-spread indirectly via distress-selection. ; This plugin calls 'gegl:noise-spread' indirectly via distress-selection.
; plug-in-spread is a compatability plug-in to gegl:noise-spread.
; gegl:noise-spread seems to have a limit of 512. ; gegl:noise-spread seems to have a limit of 512.
; Here we limit to 200, for undocumented reasons. ; Here we limit to 200, for undocumented reasons.
(set! theSpread (/ theSize 25)) (set! theSpread (/ theSize 25))

View file

@ -84,11 +84,7 @@
(/ theHeight inGranu) (/ theHeight inGranu)
TRUE) TRUE)
(plug-in-spread RUN-NONINTERACTIVE (gimp-drawable-merge-new-filter theLayer "gegl:noise-spread" 0 LAYER-MODE-REPLACE 1.0 "amount-x" inSpread "amount-y" inSpread "seed" (msrg-rand))
theImage
theLayer
inSpread
inSpread)
(plug-in-gauss RUN-NONINTERACTIVE (plug-in-gauss RUN-NONINTERACTIVE
theImage theLayer horizontalRadius verticalRadius 0) theImage theLayer horizontalRadius verticalRadius 0)

View file

@ -85,11 +85,7 @@
(/ theHeight inGranu) (/ theHeight inGranu)
TRUE) TRUE)
(plug-in-spread RUN-NONINTERACTIVE (gimp-drawable-merge-new-filter theLayer "gegl:noise-spread" 0 LAYER-MODE-REPLACE 1.0 "amount-x" (/ inSize inGranu) "amount-y" (/ inSize inGranu) "seed" (msrg-rand))
theImage
theLayer
(/ inSize inGranu)
(/ inSize inGranu))
(chris-color-edge theImage theLayer inColor 1) (chris-color-edge theImage theLayer inColor 1)
(gimp-layer-scale theLayer theWidth theHeight TRUE) (gimp-layer-scale theLayer theWidth theHeight TRUE)