Skip to content

Commit 082ba3b

Browse files
author
Jehan
committed
app, pdb, plug-ins: replace (plug-in-waves).
For plug-in writers reference, these are equivalent: - (plug-in-waves RUN-NONINTERACTIVE - image - source-layer - amplitude - phase - wavelength - 0 - FALSE) + + (let* ( + (phi phase) + (width (car (gimp-drawable-get-width source-layer))) + (height (car (gimp-drawable-get-height source-layer))) + (aspect (/ width height)) + ) + + (while (< phi 0) + (set! phi (+ phi 360.0)) + ) + (set! phi (/ (- (modulo phase 360.0) 180.0) 180.0)) + + (if (< aspect 0.1) + (set! aspect 0.1)) + (if (> aspect 10.0) + (set! aspect 10.0)) + (gimp-drawable-merge-new-filter source-layer "gegl:waves" 0 LAYER-MODE-REPLACE 1.0 "amplitude" amplitude "phi" phi + "period" (* wavelength 2.0) + "clamp" TRUE "aspect" aspect) + ) Notes: * The old type argument is the negated value of "clamp". * The last argument (reflective) was unused.
1 parent c70ffce commit 082ba3b

File tree

4 files changed

+38
-219
lines changed

4 files changed

+38
-219
lines changed

app/pdb/internal-procs.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#include "internal-procs.h"
3131

3232

33-
/* 726 procedures registered total */
33+
/* 725 procedures registered total */
3434

3535
void
3636
internal_procs_init (GimpPDB *pdb)

app/pdb/plug-in-compat-cmds.c

-129
Original file line numberDiff line numberDiff line change
@@ -916,69 +916,6 @@ plug_in_noisify_invoker (GimpProcedure *procedure,
916916
error ? *error : NULL);
917917
}
918918

919-
static GimpValueArray *
920-
plug_in_waves_invoker (GimpProcedure *procedure,
921-
Gimp *gimp,
922-
GimpContext *context,
923-
GimpProgress *progress,
924-
const GimpValueArray *args,
925-
GError **error)
926-
{
927-
gboolean success = TRUE;
928-
GimpDrawable *drawable;
929-
gdouble amplitude;
930-
gdouble phase;
931-
gdouble wavelength;
932-
gboolean type;
933-
934-
drawable = g_value_get_object (gimp_value_array_index (args, 2));
935-
amplitude = g_value_get_double (gimp_value_array_index (args, 3));
936-
phase = g_value_get_double (gimp_value_array_index (args, 4));
937-
wavelength = g_value_get_double (gimp_value_array_index (args, 5));
938-
type = g_value_get_boolean (gimp_value_array_index (args, 6));
939-
940-
if (success)
941-
{
942-
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
943-
GIMP_PDB_ITEM_CONTENT, error) &&
944-
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
945-
{
946-
GeglNode *node;
947-
gdouble width = gimp_item_get_width (GIMP_ITEM (drawable));
948-
gdouble height = gimp_item_get_height (GIMP_ITEM (drawable));
949-
gdouble aspect;
950-
951-
while (phase < 0)
952-
phase += 360.0;
953-
954-
phase = fmod (phase, 360.0);
955-
956-
aspect = CLAMP (width / height, 0.1, 10.0);
957-
958-
node = gegl_node_new_child (NULL,
959-
"operation", "gegl:waves",
960-
"x", 0.5,
961-
"y", 0.5,
962-
"amplitude", amplitude,
963-
"phi", (phase - 180.0) / 180.0,
964-
"period", wavelength * 2.0,
965-
"aspect", aspect,
966-
"clamp", ! type,
967-
NULL);
968-
969-
gimp_drawable_apply_operation (drawable, progress,
970-
C_("undo-type", "Waves"),
971-
node);
972-
g_object_unref (node);
973-
}
974-
else
975-
success = FALSE;
976-
}
977-
978-
return gimp_procedure_get_return_values (procedure, success,
979-
error ? *error : NULL);
980-
}
981-
982919
void
983920
register_plug_in_compat_procs (GimpPDB *pdb)
984921
{
@@ -1511,70 +1448,4 @@ register_plug_in_compat_procs (GimpPDB *pdb)
15111448
GIMP_PARAM_READWRITE));
15121449
gimp_pdb_register_procedure (pdb, procedure);
15131450
g_object_unref (procedure);
1514-
1515-
/*
1516-
* gimp-plug-in-waves
1517-
*/
1518-
procedure = gimp_procedure_new (plug_in_waves_invoker);
1519-
gimp_object_set_static_name (GIMP_OBJECT (procedure),
1520-
"plug-in-waves");
1521-
gimp_procedure_set_static_help (procedure,
1522-
"Distort the image with waves",
1523-
"Distort the image with waves.",
1524-
NULL);
1525-
gimp_procedure_set_static_attribution (procedure,
1526-
"Compatibility procedure. Please see 'gegl:waves' for credits.",
1527-
"Compatibility procedure. Please see 'gegl:waves' for credits.",
1528-
"2013");
1529-
gimp_procedure_add_argument (procedure,
1530-
g_param_spec_enum ("run-mode",
1531-
"run mode",
1532-
"The run mode",
1533-
GIMP_TYPE_RUN_MODE,
1534-
GIMP_RUN_INTERACTIVE,
1535-
GIMP_PARAM_READWRITE));
1536-
gimp_procedure_add_argument (procedure,
1537-
gimp_param_spec_image ("image",
1538-
"image",
1539-
"Input image (unused)",
1540-
FALSE,
1541-
GIMP_PARAM_READWRITE));
1542-
gimp_procedure_add_argument (procedure,
1543-
gimp_param_spec_drawable ("drawable",
1544-
"drawable",
1545-
"Input drawable",
1546-
FALSE,
1547-
GIMP_PARAM_READWRITE));
1548-
gimp_procedure_add_argument (procedure,
1549-
g_param_spec_double ("amplitude",
1550-
"amplitude",
1551-
"The Amplitude of the Waves",
1552-
0, 101, 0,
1553-
GIMP_PARAM_READWRITE));
1554-
gimp_procedure_add_argument (procedure,
1555-
g_param_spec_double ("phase",
1556-
"phase",
1557-
"The Phase of the Waves",
1558-
-360, 360, -360,
1559-
GIMP_PARAM_READWRITE));
1560-
gimp_procedure_add_argument (procedure,
1561-
g_param_spec_double ("wavelength",
1562-
"wavelength",
1563-
"The Wavelength of the Waves",
1564-
0.1, 100, 0.1,
1565-
GIMP_PARAM_READWRITE));
1566-
gimp_procedure_add_argument (procedure,
1567-
g_param_spec_boolean ("type",
1568-
"type",
1569-
"Type of waves: { 0 = smeared, 1 = black }",
1570-
FALSE,
1571-
GIMP_PARAM_READWRITE));
1572-
gimp_procedure_add_argument (procedure,
1573-
g_param_spec_boolean ("reflective",
1574-
"reflective",
1575-
"Use Reflection (not implemented)",
1576-
FALSE,
1577-
GIMP_PARAM_READWRITE));
1578-
gimp_pdb_register_procedure (pdb, procedure);
1579-
g_object_unref (procedure);
15801451
}

pdb/groups/plug_in_compat.pdb

+1-73
Original file line numberDiff line numberDiff line change
@@ -575,77 +575,6 @@ CODE
575575
);
576576
}
577577

578-
sub plug_in_waves {
579-
$blurb = 'Distort the image with waves';
580-
581-
$help = <<'HELP';
582-
Distort the image with waves.
583-
HELP
584-
585-
&std_pdb_compat('gegl:waves');
586-
$date = '2013';
587-
588-
@inargs = (
589-
{ name => 'run_mode', type => 'enum GimpRunMode', dead => 1,
590-
desc => 'The run mode' },
591-
{ name => 'image', type => 'image', dead => 1,
592-
desc => 'Input image (unused)' },
593-
{ name => 'drawable', type => 'drawable',
594-
desc => 'Input drawable' },
595-
{ name => 'amplitude', type => '0 <= double <= 101',
596-
desc => 'The Amplitude of the Waves' },
597-
{ name => 'phase', type => '-360 <= double <= 360',
598-
desc => 'The Phase of the Waves' },
599-
{ name => 'wavelength', type => '0.1 <= double <= 100',
600-
desc => 'The Wavelength of the Waves' },
601-
{ name => 'type', type => 'boolean',
602-
desc => 'Type of waves: { 0 = smeared, 1 = black }' },
603-
{ name => 'reflective', type => 'boolean', dead => 1,
604-
desc => 'Use Reflection (not implemented)' }
605-
);
606-
607-
%invoke = (
608-
code => <<'CODE'
609-
{
610-
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
611-
GIMP_PDB_ITEM_CONTENT, error) &&
612-
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
613-
{
614-
GeglNode *node;
615-
gdouble width = gimp_item_get_width (GIMP_ITEM (drawable));
616-
gdouble height = gimp_item_get_height (GIMP_ITEM (drawable));
617-
gdouble aspect;
618-
619-
while (phase < 0)
620-
phase += 360.0;
621-
622-
phase = fmod (phase, 360.0);
623-
624-
aspect = CLAMP (width / height, 0.1, 10.0);
625-
626-
node = gegl_node_new_child (NULL,
627-
"operation", "gegl:waves",
628-
"x", 0.5,
629-
"y", 0.5,
630-
"amplitude", amplitude,
631-
"phi", (phase - 180.0) / 180.0,
632-
"period", wavelength * 2.0,
633-
"aspect", aspect,
634-
"clamp", ! type,
635-
NULL);
636-
637-
gimp_drawable_apply_operation (drawable, progress,
638-
C_("undo-type", "Waves"),
639-
node);
640-
g_object_unref (node);
641-
}
642-
else
643-
success = FALSE;
644-
}
645-
CODE
646-
);
647-
}
648-
649578
$extra{app}->{code} = <<'CODE';
650579
static GeglNode *
651580
wrap_in_graph (GeglNode *node)
@@ -1044,8 +973,7 @@ CODE
1044973
plug_in_gauss
1045974
plug_in_plasma
1046975
plug_in_rotate
1047-
plug_in_noisify
1048-
plug_in_waves);
976+
plug_in_noisify);
1049977

1050978
%exports = (app => [@procs], lib => []);
1051979

plug-ins/script-fu/scripts/waves-anim.scm

+36-16
Original file line numberDiff line numberDiff line change
@@ -57,34 +57,54 @@
5757
remaining-frames) 10
5858
)
5959
" (replace)"))
60+
(phi phase)
61+
(width (car (gimp-drawable-get-width waves-layer)))
62+
(height (car (gimp-drawable-get-height waves-layer)))
63+
(aspect (/ width height))
6064
)
6165
(gimp-layer-set-lock-alpha waves-layer FALSE)
6266
(gimp-image-insert-layer image waves-layer 0 -1)
6367
(gimp-item-set-name waves-layer layer-name)
6468

65-
(plug-in-waves RUN-NONINTERACTIVE
66-
image
67-
waves-layer
68-
amplitude
69-
phase
70-
wavelength
71-
0
72-
FALSE)
69+
(while (< phi 0)
70+
(set! phi (+ phi 360.0))
71+
)
72+
(set! phi (/ (- (modulo phase 360.0) 180.0) 180.0))
73+
(if (< aspect 0.1)
74+
(set! aspect 0.1))
75+
(if (> aspect 10.0)
76+
(set! aspect 10.0))
77+
(gimp-drawable-merge-new-filter waves-layer "gegl:waves" 0 LAYER-MODE-REPLACE 1.0 "amplitude" amplitude "phi" phi
78+
"period" (* wavelength 2.0)
79+
"clamp" TRUE "aspect" aspect)
7380

7481
(set! remaining-frames (- remaining-frames 1))
7582
(set! phase (- phase phaseshift))
7683
)
7784
)
7885

7986
(gimp-item-set-name source-layer "Frame 1")
80-
(plug-in-waves RUN-NONINTERACTIVE
81-
image
82-
source-layer
83-
amplitude
84-
phase
85-
wavelength
86-
0
87-
FALSE)
87+
88+
(let* (
89+
(phi phase)
90+
(width (car (gimp-drawable-get-width source-layer)))
91+
(height (car (gimp-drawable-get-height source-layer)))
92+
(aspect (/ width height))
93+
)
94+
95+
(while (< phi 0)
96+
(set! phi (+ phi 360.0))
97+
)
98+
(set! phi (/ (- (modulo phase 360.0) 180.0) 180.0))
99+
100+
(if (< aspect 0.1)
101+
(set! aspect 0.1))
102+
(if (> aspect 10.0)
103+
(set! aspect 10.0))
104+
(gimp-drawable-merge-new-filter source-layer "gegl:waves" 0 LAYER-MODE-REPLACE 1.0 "amplitude" amplitude "phi" phi
105+
"period" (* wavelength 2.0)
106+
"clamp" TRUE "aspect" aspect)
107+
)
88108

89109
(gimp-image-undo-enable image)
90110
(gimp-display-new image)

0 commit comments

Comments
 (0)