Commit a4a0ec95 authored by Michael Natterer's avatar Michael Natterer

plug-ins, pdb: remove the maze plug-in and add a PDB compat proc

parent 3f02b2aa
......@@ -28,7 +28,7 @@
#include "internal-procs.h"
/* 772 procedures registered total */
/* 773 procedures registered total */
void
internal_procs_init (GimpPDB *pdb)
......
......@@ -2397,6 +2397,73 @@ plug_in_make_seamless_invoker (GimpProcedure *procedure,
error ? *error : NULL);
}
static GimpValueArray *
plug_in_maze_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpDrawable *drawable;
gint16 width;
gint16 height;
guint8 tileable;
guint8 algorithm;
gint32 seed;
drawable = gimp_value_get_drawable (gimp_value_array_index (args, 2), gimp);
width = g_value_get_int (gimp_value_array_index (args, 3));
height = g_value_get_int (gimp_value_array_index (args, 4));
tileable = g_value_get_uint (gimp_value_array_index (args, 5));
algorithm = g_value_get_uint (gimp_value_array_index (args, 6));
seed = g_value_get_int (gimp_value_array_index (args, 7));
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;
GeglColor *fg_color;
GeglColor *bg_color;
GimpRGB color;
gimp_context_get_foreground (context, &color);
fg_color = gimp_gegl_color_new (&color);
gimp_context_get_background (context, &color);
bg_color = gimp_gegl_color_new (&color);
node = gegl_node_new_child (NULL,
"operation", "gegl:maze",
"x", width,
"y", height,
"algorithm-type", algorithm,
"tilable", tileable,
"seed", seed,
"fg-color", fg_color,
"bg-color", bg_color,
NULL);
g_object_unref (fg_color);
g_object_unref (bg_color);
gimp_drawable_apply_operation (drawable, progress,
C_("undo-type", "Maze"),
node);
g_object_unref (node);
}
else
success = FALSE;
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GimpValueArray *
plug_in_mblur_invoker (GimpProcedure *procedure,
Gimp *gimp,
......@@ -6452,6 +6519,84 @@ register_plug_in_compat_procs (GimpPDB *pdb)
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-plug-in-maze
*/
procedure = gimp_procedure_new (plug_in_maze_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"plug-in-maze");
gimp_procedure_set_static_strings (procedure,
"plug-in-maze",
"Draw a labyrinth",
"Generates a maze using either the depth-first search method or Prim's algorithm. Can make tileable mazes too.",
"Compatibility procedure. Please see 'gegl:maze' for credits.",
"Compatibility procedure. Please see 'gegl:maze' for credits.",
"2015",
NULL);
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_id ("image",
"image",
"Input image (unused)",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",
"Input drawable",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int16 ("width",
"width",
"Width of the passages",
1, 1024, 1,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int16 ("height",
"height",
"Height of the passages",
1, 1024, 1,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int8 ("tileable",
"tileable",
"Tileable maze? (TRUE or FALSE)",
0, 1, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int8 ("algorithm",
"algorithm",
"Generation algorithm (0 = DEPTH FIRST, 1 = PRIM'S ALGORITHM)",
0, 1, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int32 ("seed",
"seed",
"Random Seed",
G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int16 ("multiple",
"multiple",
"Multiple (use 57)",
G_MININT16, G_MAXINT16, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int16 ("offset",
"offset",
"Offset (use 1)",
G_MININT16, G_MAXINT16, 0,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-plug-in-mblur
*/
......
......@@ -2312,7 +2312,6 @@ plug-ins/imagemap/images/Makefile
plug-ins/lighting/Makefile
plug-ins/lighting/images/Makefile
plug-ins/map-object/Makefile
plug-ins/maze/Makefile
plug-ins/pagecurl/Makefile
plug-ins/print/Makefile
plug-ins/pygimp/Makefile
......
......@@ -52,7 +52,6 @@ SUBDIRS = \
imagemap \
lighting \
map-object \
maze \
pagecurl \
$(print) \
selection-to-path \
......
/Makefile.in
/Makefile
/.deps
/_libs
/.libs
/maze
/maze.exe
## Process this file with automake to produce Makefile.in
libgimpui = $(top_builddir)/libgimp/libgimpui-$(GIMP_API_VERSION).la
libgimpconfig = $(top_builddir)/libgimpconfig/libgimpconfig-$(GIMP_API_VERSION).la
libgimpwidgets = $(top_builddir)/libgimpwidgets/libgimpwidgets-$(GIMP_API_VERSION).la
libgimp = $(top_builddir)/libgimp/libgimp-$(GIMP_API_VERSION).la
libgimpcolor = $(top_builddir)/libgimpcolor/libgimpcolor-$(GIMP_API_VERSION).la
libgimpbase = $(top_builddir)/libgimpbase/libgimpbase-$(GIMP_API_VERSION).la
libgimpmath = $(top_builddir)/libgimpmath/libgimpmath-$(GIMP_API_VERSION).la
if OS_WIN32
mwindows = -mwindows
endif
if HAVE_WINDRES
include $(top_srcdir)/build/windows/gimprc-plug-ins.rule
maze_RC = maze.rc.o
endif
AM_LDFLAGS = $(mwindows)
libexecdir = $(gimpplugindir)/plug-ins
libexec_PROGRAMS = maze
maze_SOURCES = \
maze.c \
maze.h \
maze-algorithms.c \
maze-algorithms.h \
maze-dialog.c \
maze-dialog.h \
maze-utils.c \
maze-utils.h
AM_CPPFLAGS = \
-I$(top_srcdir) \
$(GTK_CFLAGS) \
$(GEGL_CFLAGS) \
-I$(includedir)
LDADD = \
$(libgimpui) \
$(libgimpwidgets) \
$(libgimpconfig) \
$(libgimp) \
$(libgimpcolor) \
$(libgimpmath) \
$(libgimpbase) \
$(GTK_LIBS) \
$(RT_LIBS) \
$(INTLLIBS) \
$(maze_RC)
This diff is collapsed.
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __MAZE_ALGORITHMS_H__
#define __MAZE_ALGORITHMS_H__
void mazegen (gint pos,
guchar *maz,
gint x,
gint y,
gint rnd);
void mazegen_tileable (gint pos,
guchar *maz,
gint x,
gint y,
gint rnd);
void prim (gint pos,
guchar *maz,
guint x,
guint y);
void prim_tileable (guchar *maz,
guint x,
guint y);
#endif /* __MAZE_ALGORITHMS_H__ */
This diff is collapsed.
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __MAZE_DIALOG_H__
#define __MAZE_DIALOG_H__
gboolean maze_dialog (void);
#endif /* __MAZE_DIALOG_H__ */
/* $Id$
* These routines are useful for working with GIMP and need not be
* specific to plug-in-maze.
*
* Kevin Turner <acapnotic@users.sourceforge.net>
* http://gimp-plug-ins.sourceforge.net/maze/
*/
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <string.h>
#include "libgimp/gimp.h"
#include "maze-utils.h"
/* get_colors Returns the current foreground and background colors in
nice little arrays. It works nicely for RGB and grayscale images,
however handling of indexed images is somewhat broken. Patches
appreciated. */
void
get_colors (GimpDrawable *drawable,
guint8 *fg,
guint8 *bg)
{
GimpRGB foreground;
GimpRGB background;
gimp_context_get_foreground (&foreground);
gimp_context_get_background (&background);
fg[0] = fg[1] = fg[2] = fg[3] = 255;
bg[0] = bg[1] = bg[2] = bg[3] = 255;
switch (gimp_drawable_type (drawable->drawable_id))
{
case GIMP_RGB_IMAGE:
case GIMP_RGBA_IMAGE:
gimp_rgb_get_uchar (&foreground, &fg[0], &fg[1], &fg[2]);
gimp_rgb_get_uchar (&background, &bg[0], &bg[1], &bg[2]);
break;
case GIMP_GRAYA_IMAGE:
case GIMP_GRAY_IMAGE:
fg[0] = gimp_rgb_luminance_uchar (&foreground);
bg[0] = gimp_rgb_luminance_uchar (&background);
break;
case GIMP_INDEXEDA_IMAGE:
case GIMP_INDEXED_IMAGE: /* FIXME: Should use current fg/bg colors. */
g_warning("maze: get_colors: Indexed image. Using colors 15 and 0.\n");
fg[0] = 15; /* As a plugin, I protest. *I* shouldn't be the */
bg[0] = 0; /* one who has to deal with this colormapcrap. */
break;
default:
break;
}
}
/* Draws a solid color box in a GimpPixelRgn. */
/* Optimization assumptions:
* (Or, "Why Maze is Faster Than Checkerboard.")
*
* Assuming calling memcpy is faster than using loops.
* Row buffers are nice...
*
* Assume allocating memory for row buffers takes a significant amount
* of time. Assume drawbox will be called many times.
* Only allocate memory once.
*
* Do not assume the row buffer will always be the same size. Allow
* for reallocating to make it bigger if needed. However, I don't see
* reason to bother ever shrinking it again.
* (Under further investigation, assuming the row buffer never grows
* may be a safe assumption in this case.)
*
* Also assume that the program calling drawbox is short-lived, so
* memory leaks aren't of particular concern-- the memory allocated to
* the row buffer is never set free.
*/
/* Further optimizations that could be made...
* Currently, the row buffer is re-filled with every call. However,
* plug-ins such as maze and checkerboard only use two colors, and
* for the most part, have rows of the same size with every call.
* We could keep a row of each color on hand so we wouldn't have to
* re-fill it every time... */
void
drawbox (GimpPixelRgn *dest_rgn,
guint x,
guint y,
guint w,
guint h,
guint8 clr[4])
{
const guint bpp = dest_rgn->bpp;
const guint x_min = x * bpp;
/* x_max = dest_rgn->bpp * MIN(dest_rgn->w, (x + w)); */
/* rowsize = x_max - x_min */
const guint rowsize = bpp * MIN (dest_rgn->w, (x + w)) - x_min;
/* The maximum [xy] value is that of the far end of the box, or
* the edge of the region, whichever comes first. */
const guint y_max = dest_rgn->rowstride * MIN (dest_rgn->h, (y + h));
static guint8 *rowbuf;
static guint high_size = 0;
guint xx, yy;
/* Does the row buffer need to be (re)allocated? */
if (high_size == 0)
{
rowbuf = g_new (guint8, rowsize);
}
else if (rowsize > high_size)
{
rowbuf = g_renew (guint8, rowbuf, rowsize);
}
high_size = MAX (high_size, rowsize);
/* Fill the row buffer with the color. */
for (xx = 0; xx < rowsize; xx += bpp)
{
memcpy (&rowbuf[xx], clr, bpp);
}
/* Fill in the box in the region with rows... */
for (yy = dest_rgn->rowstride * y; yy < y_max; yy += dest_rgn->rowstride)
{
memcpy (&dest_rgn->data[yy + x_min], rowbuf, rowsize);
}
}
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __MAZE_UTILS_H__
#define __MAZE_UTILS_H__
void get_colors (GimpDrawable *drawable,
guint8 *fg,
guint8 *bg);
void drawbox (GimpPixelRgn *dest_rgn,
guint x,
guint y,
guint w,
guint h,
guint8 clr[4]);
#endif /* __MAZE_UTILS_H__ */
This diff is collapsed.
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __MAZE_H__
#define __MAZE_H__
/* The "divbox" really should look and act more like a spinbutton.
This flag is a small step in the direction toward the former, the
latter leaves much to be desired. */
#define DIVBOX_LOOKS_LIKE_SPINBUTTON FALSE
/* Don't update the progress for every cell when creating a maze.
Instead, update every . . . */
#define PRIMS_PROGRESS_UPDATE 256
/* Don't draw in anything that has less than
this value in the selection channel. */
#define MAZE_ALPHA_THRESHOLD 127
#define PLUG_IN_PROC "plug-in-maze"
#define PLUG_IN_BINARY "maze"
#define PLUG_IN_ROLE "gimp-maze"
typedef enum {
DEPTH_FIRST,
PRIMS_ALGORITHM
} MazeAlgoType;
typedef struct {
gint width;
gint height;
guint32 seed;
gboolean tile;
gint multiple;
gint offset;
MazeAlgoType algorithm;
gboolean random_seed;
/* Interface options. */
} MazeValues;
enum CellTypes {
OUT,
IN,
FRONTIER,
MASKED
};
extern MazeValues mvals;
extern gint sel_w;
extern gint sel_h;
extern GRand *gr;
#endif /* __MAZE_H__ */
......@@ -211,10 +211,6 @@ plug-ins/lighting/lighting-ui.c
plug-ins/map-object/map-object-apply.c
plug-ins/map-object/map-object-main.c
plug-ins/map-object/map-object-ui.c
plug-ins/maze/maze-algorithms.c
plug-ins/maze/maze-dialog.c
plug-ins/maze/maze.c
plug-ins/maze/maze.h
plug-ins/pagecurl/pagecurl.c
plug-ins/print/print-draw-page.c
plug-ins/print/print-page-layout.c
......
......@@ -2338,6 +2338,84 @@ CODE
);
}
sub plug_in_maze {
$blurb = 'Draw a labyrinth';
$help = <<'HELP';
Generates a maze using either the depth-first search method or Prim's
algorithm. Can make tileable mazes too.
HELP
&std_pdb_compat('gegl:maze');
$date = '2015';
@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 => 'width', type => '1 <= int16 <= 1024',
desc => 'Width of the passages' },
{ name => 'height', type => '1 <= int16 <= 1024',
desc => 'Height of the passages' },
{ name => 'tileable', type => '0 <= int8 <= 1',
desc => 'Tileable maze? (TRUE or FALSE)' },
{ name => 'algorithm', type => '0 <= int8 <= 1',
desc => 'Generation algorithm (0 = DEPTH FIRST, 1 = PRIM\'S ALGORITHM)' },
{ name => 'seed', type => 'int32',
desc => 'Random Seed' },
{ name => 'multiple', type => 'int16', dead => 1,
desc => 'Multiple (use 57)' },
{ name => 'offset', type => 'int16', dead => 1,
desc => 'Offset (use 1)' }
);
%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;
GeglColor *fg_color;
GeglColor *bg_color;
GimpRGB color;
gimp_context_get_foreground (context, &color);
fg_color = gimp_gegl_color_new (&color);
gimp_context_get_background (context, &color);
bg_color = gimp_gegl_color_new (&color);
node = gegl_node_new_child (NULL,
"operation", "gegl:maze",
"x", width,
"y", height,
"algorithm-type", algorithm,
"tilable", tileable,
"seed", seed,
"fg-color", fg_color,
"bg-color", bg_color,
NULL);
g_object_unref (fg_color);
g_object_unref (bg_color);
gimp_drawable_apply_operation (drawable, progress,
C_("undo-type", "Maze"),
node);
g_object_unref (node);
}
else
success = FALSE;
}
CODE
);
}
sub plug_in_mblur {
$blurb = 'Simulate movement using directional blur';
......@@ -4779,6 +4857,7 @@ CODE
plug_in_laplace
plug_in_lens_distortion
plug_in_make_seamless
plug_in_maze
plug_in_mblur
plug_in_mblur_inward
plug_in_mosaic
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment