2004-11-05 19:35:38 +08:00
|
|
|
/* flame - cosmic recursive fractal flames
|
|
|
|
* Copyright (C) 1997 Scott Draves <spot@cs.cmu.edu>
|
|
|
|
*
|
2006-12-10 05:33:38 +08:00
|
|
|
* GIMP - The GNU Image Manipulation Program
|
2004-11-05 19:35:38 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2004-11-05 19:35:38 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2004-11-05 19:35:38 +08:00
|
|
|
* (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
|
2018-07-12 05:27:07 +08:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2004-11-05 19:35:38 +08:00
|
|
|
*/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-05-29 09:28:24 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <errno.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
2005-03-04 21:23:32 +08:00
|
|
|
#include <glib/gstdio.h>
|
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
#include <libgimp/gimp.h>
|
|
|
|
#include <libgimp/gimpui.h>
|
|
|
|
|
2004-11-05 19:35:38 +08:00
|
|
|
#include "flame.h"
|
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
#include "libgimp/stdplugins-intl.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
|
2005-08-12 23:46:46 +08:00
|
|
|
#define PLUG_IN_PROC "plug-in-flame"
|
2008-08-12 03:42:08 +08:00
|
|
|
#define PLUG_IN_BINARY "flame"
|
2011-04-09 02:31:34 +08:00
|
|
|
#define PLUG_IN_ROLE "gimp-flame"
|
2004-11-05 19:35:38 +08:00
|
|
|
|
2005-08-12 23:46:46 +08:00
|
|
|
#define VARIATION_SAME (-2)
|
2004-11-05 19:35:38 +08:00
|
|
|
|
|
|
|
#define BUFFER_SIZE 10000
|
|
|
|
|
|
|
|
#define PREVIEW_SIZE 150
|
|
|
|
#define EDIT_PREVIEW_SIZE 85
|
|
|
|
#define NMUTANTS 9
|
|
|
|
|
|
|
|
#define BLACK_DRAWABLE (-2)
|
|
|
|
#define GRADIENT_DRAWABLE (-3)
|
|
|
|
#define TABLE_DRAWABLE (-4)
|
|
|
|
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
gint randomize; /* superseded */
|
|
|
|
gint variation;
|
2019-08-31 20:42:33 +08:00
|
|
|
gint32 cmap_drawable_id;
|
2004-11-05 19:35:38 +08:00
|
|
|
control_point cp;
|
|
|
|
} config;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-01-21 01:10:16 +08:00
|
|
|
|
2019-08-31 20:42:33 +08:00
|
|
|
typedef struct _Flame Flame;
|
|
|
|
typedef struct _FlameClass FlameClass;
|
|
|
|
|
|
|
|
struct _Flame
|
|
|
|
{
|
|
|
|
GimpPlugIn parent_instance;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _FlameClass
|
|
|
|
{
|
|
|
|
GimpPlugInClass parent_class;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#define FLAME_TYPE (flame_get_type ())
|
|
|
|
#define FLAME (obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FLAME_TYPE, Flame))
|
|
|
|
|
|
|
|
GType flame_get_type (void) G_GNUC_CONST;
|
|
|
|
|
|
|
|
static GList * flame_query_procedures (GimpPlugIn *plug_in);
|
|
|
|
static GimpProcedure * flame_create_procedure (GimpPlugIn *plug_in,
|
|
|
|
const gchar *name);
|
|
|
|
|
|
|
|
static GimpValueArray * flame_run (GimpProcedure *procedure,
|
|
|
|
GimpRunMode run_mode,
|
|
|
|
GimpImage *image,
|
2021-04-02 08:55:46 +08:00
|
|
|
gint n_drawables,
|
|
|
|
GimpDrawable **drawables,
|
2019-08-31 20:42:33 +08:00
|
|
|
const GimpValueArray *args,
|
|
|
|
gpointer run_data);
|
|
|
|
|
|
|
|
static void flame (GimpDrawable *drawable);
|
|
|
|
|
|
|
|
static gboolean flame_dialog (void);
|
|
|
|
static void set_flame_preview (void);
|
|
|
|
static void load_callback (GtkWidget *widget,
|
|
|
|
gpointer data);
|
|
|
|
static void save_callback (GtkWidget *widget,
|
|
|
|
gpointer data);
|
|
|
|
static void set_edit_preview (void);
|
|
|
|
static void combo_callback (GtkWidget *widget,
|
|
|
|
gpointer data);
|
|
|
|
static void init_mutants (void);
|
2004-11-05 19:35:38 +08:00
|
|
|
|
2020-11-06 00:37:15 +08:00
|
|
|
static void flame_scale_entry_update_int (GimpLabelSpin *entry,
|
2020-10-31 07:53:26 +08:00
|
|
|
gint *value);
|
2020-11-06 00:37:15 +08:00
|
|
|
static void flame_scale_entry_update_double (GimpLabelSpin *entry,
|
2020-10-31 07:53:26 +08:00
|
|
|
gdouble *value);
|
2004-05-20 23:51:25 +08:00
|
|
|
|
2019-08-31 20:42:33 +08:00
|
|
|
G_DEFINE_TYPE (Flame, flame, GIMP_TYPE_PLUG_IN)
|
|
|
|
|
|
|
|
GIMP_MAIN (FLAME_TYPE)
|
2022-05-26 06:59:36 +08:00
|
|
|
DEFINE_STD_SET_I18N
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
|
|
|
|
static gchar buffer[BUFFER_SIZE];
|
|
|
|
static GtkWidget *cmap_preview;
|
|
|
|
static GtkWidget *flame_preview;
|
|
|
|
static gint preview_width, preview_height;
|
2005-09-10 02:07:31 +08:00
|
|
|
static GtkWidget *dialog;
|
2000-04-01 23:48:48 +08:00
|
|
|
static GtkWidget *load_button = NULL;
|
|
|
|
static GtkWidget *save_button = NULL;
|
2005-09-10 02:07:31 +08:00
|
|
|
static GtkWidget *file_dialog = NULL;
|
2000-04-01 23:48:48 +08:00
|
|
|
static gint load_save;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-09-10 02:07:31 +08:00
|
|
|
static GtkWidget *edit_dialog = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
static control_point edit_cp;
|
|
|
|
static control_point mutants[NMUTANTS];
|
|
|
|
static GtkWidget *edit_previews[NMUTANTS];
|
|
|
|
static gdouble pick_speed = 0.2;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-11-05 19:35:38 +08:00
|
|
|
static frame_spec f = { 0.0, &config.cp, 1, 0.0 };
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2019-08-31 20:42:33 +08:00
|
|
|
static void
|
|
|
|
flame_class_init (FlameClass *klass)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2019-08-31 20:42:33 +08:00
|
|
|
GimpPlugInClass *plug_in_class = GIMP_PLUG_IN_CLASS (klass);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2019-08-31 20:42:33 +08:00
|
|
|
plug_in_class->query_procedures = flame_query_procedures;
|
|
|
|
plug_in_class->create_procedure = flame_create_procedure;
|
2022-05-26 06:59:36 +08:00
|
|
|
plug_in_class->set_i18n = STD_SET_I18N;
|
2019-08-31 20:42:33 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2019-08-31 20:42:33 +08:00
|
|
|
static void
|
|
|
|
flame_init (Flame *flame)
|
|
|
|
{
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2019-08-31 20:42:33 +08:00
|
|
|
static GList *
|
|
|
|
flame_query_procedures (GimpPlugIn *plug_in)
|
|
|
|
{
|
|
|
|
return g_list_append (NULL, g_strdup (PLUG_IN_PROC));
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2019-08-31 20:42:33 +08:00
|
|
|
static GimpProcedure *
|
|
|
|
flame_create_procedure (GimpPlugIn *plug_in,
|
|
|
|
const gchar *name)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2019-08-31 20:42:33 +08:00
|
|
|
GimpProcedure *procedure = NULL;
|
|
|
|
|
|
|
|
if (! strcmp (name, PLUG_IN_PROC))
|
|
|
|
{
|
|
|
|
procedure = gimp_image_procedure_new (plug_in, name,
|
|
|
|
GIMP_PDB_PROC_TYPE_PLUGIN,
|
|
|
|
flame_run, NULL, NULL);
|
|
|
|
|
|
|
|
gimp_procedure_set_image_types (procedure, "RGB*");
|
2021-04-02 08:55:46 +08:00
|
|
|
gimp_procedure_set_sensitivity_mask (procedure,
|
|
|
|
GIMP_PROCEDURE_SENSITIVE_DRAWABLE);
|
2019-08-31 20:42:33 +08:00
|
|
|
|
2022-07-05 04:50:53 +08:00
|
|
|
gimp_procedure_set_menu_label (procedure, _("_Flame..."));
|
2019-08-31 20:42:33 +08:00
|
|
|
gimp_procedure_add_menu_path (procedure,
|
|
|
|
"<Image>/Filters/Render/Fractals");
|
|
|
|
|
|
|
|
gimp_procedure_set_documentation (procedure,
|
2022-07-05 04:50:53 +08:00
|
|
|
_("Create cosmic recursive fractal "
|
|
|
|
"flames"),
|
2019-08-31 20:42:33 +08:00
|
|
|
"Create cosmic recursive fractal flames",
|
|
|
|
name);
|
|
|
|
gimp_procedure_set_attribution (procedure,
|
|
|
|
"Scott Draves",
|
|
|
|
"Scott Draves",
|
|
|
|
"1997");
|
|
|
|
}
|
|
|
|
|
|
|
|
return procedure;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-08-18 20:17:21 +08:00
|
|
|
static void
|
|
|
|
maybe_init_cp (void)
|
1999-12-27 22:14:53 +08:00
|
|
|
{
|
2000-04-01 23:48:48 +08:00
|
|
|
if (0 == config.cp.spatial_oversample)
|
|
|
|
{
|
2019-08-31 20:42:33 +08:00
|
|
|
config.randomize = 0;
|
|
|
|
config.variation = VARIATION_SAME;
|
|
|
|
config.cmap_drawable_id = GRADIENT_DRAWABLE;
|
2003-08-18 20:17:21 +08:00
|
|
|
|
|
|
|
random_control_point (&config.cp, variation_random);
|
|
|
|
|
|
|
|
config.cp.center[0] = 0.0;
|
|
|
|
config.cp.center[1] = 0.0;
|
|
|
|
config.cp.pixels_per_unit = 100;
|
|
|
|
config.cp.spatial_oversample = 2;
|
|
|
|
config.cp.gamma = 2.0;
|
|
|
|
config.cp.contrast = 1.0;
|
|
|
|
config.cp.brightness = 1.0;
|
2000-04-01 23:48:48 +08:00
|
|
|
config.cp.spatial_filter_radius = 0.75;
|
2003-08-18 20:17:21 +08:00
|
|
|
config.cp.sample_density = 5.0;
|
|
|
|
config.cp.zoom = 0.0;
|
|
|
|
config.cp.nbatches = 1;
|
|
|
|
config.cp.white_level = 200;
|
|
|
|
config.cp.cmap_index = 72;
|
2000-04-01 23:48:48 +08:00
|
|
|
/* cheating */
|
2003-08-18 20:17:21 +08:00
|
|
|
config.cp.width = 256;
|
|
|
|
config.cp.height = 256;
|
2000-04-01 23:48:48 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2019-08-31 20:42:33 +08:00
|
|
|
static GimpValueArray *
|
|
|
|
flame_run (GimpProcedure *procedure,
|
|
|
|
GimpRunMode run_mode,
|
|
|
|
GimpImage *image,
|
2021-04-02 08:55:46 +08:00
|
|
|
gint n_drawables,
|
|
|
|
GimpDrawable **drawables,
|
2019-08-31 20:42:33 +08:00
|
|
|
const GimpValueArray *args,
|
|
|
|
gpointer run_data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2021-04-02 08:55:46 +08:00
|
|
|
GimpDrawable *drawable;
|
|
|
|
|
2019-06-28 18:37:26 +08:00
|
|
|
gegl_init (NULL, NULL);
|
2003-03-26 00:38:19 +08:00
|
|
|
|
2021-04-02 08:55:46 +08:00
|
|
|
if (n_drawables != 1)
|
|
|
|
{
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
g_set_error (&error, GIMP_PLUG_IN_ERROR, 0,
|
|
|
|
_("Procedure '%s' only works with one drawable."),
|
|
|
|
PLUG_IN_PROC);
|
|
|
|
|
|
|
|
return gimp_procedure_new_return_values (procedure,
|
|
|
|
GIMP_PDB_CALLING_ERROR,
|
|
|
|
error);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
drawable = drawables[0];
|
|
|
|
}
|
|
|
|
|
2000-08-22 11:27:14 +08:00
|
|
|
if (run_mode == GIMP_RUN_NONINTERACTIVE)
|
2000-04-01 23:48:48 +08:00
|
|
|
{
|
2019-08-31 20:42:33 +08:00
|
|
|
return gimp_procedure_new_return_values (procedure,
|
|
|
|
GIMP_PDB_CALLING_ERROR,
|
|
|
|
NULL);
|
2000-04-01 23:48:48 +08:00
|
|
|
}
|
|
|
|
|
2019-08-31 20:42:33 +08:00
|
|
|
gimp_get_data (PLUG_IN_PROC, &config);
|
|
|
|
maybe_init_cp ();
|
2000-04-01 23:48:48 +08:00
|
|
|
|
2021-04-06 20:28:40 +08:00
|
|
|
config.cp.width = gimp_drawable_get_width (drawable);
|
|
|
|
config.cp.height = gimp_drawable_get_height (drawable);
|
2019-08-31 20:42:33 +08:00
|
|
|
|
|
|
|
if (run_mode == GIMP_RUN_INTERACTIVE)
|
|
|
|
{
|
|
|
|
if (! flame_dialog ())
|
2004-04-22 07:09:16 +08:00
|
|
|
{
|
2019-08-31 20:42:33 +08:00
|
|
|
return gimp_procedure_new_return_values (procedure,
|
|
|
|
GIMP_PDB_CANCEL,
|
|
|
|
NULL);
|
2004-04-22 07:09:16 +08:00
|
|
|
}
|
2019-08-31 20:42:33 +08:00
|
|
|
|
|
|
|
/* reusing a drawable from the last run is a bad idea
|
|
|
|
* since the drawable might have vanished (bug #37761)
|
|
|
|
*/
|
|
|
|
if (config.cmap_drawable_id > 0)
|
|
|
|
config.cmap_drawable_id = GRADIENT_DRAWABLE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2019-08-31 20:42:33 +08:00
|
|
|
if (gimp_drawable_is_rgb (drawable))
|
2000-04-01 23:48:48 +08:00
|
|
|
{
|
2019-08-31 20:42:33 +08:00
|
|
|
gimp_progress_init (_("Drawing flame"));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2019-08-31 20:42:33 +08:00
|
|
|
flame (drawable);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2019-08-31 20:42:33 +08:00
|
|
|
if (run_mode != GIMP_RUN_NONINTERACTIVE)
|
|
|
|
gimp_displays_flush ();
|
2004-11-05 19:35:38 +08:00
|
|
|
|
2019-08-31 20:42:33 +08:00
|
|
|
gimp_set_data (PLUG_IN_PROC, &config, sizeof (config));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return gimp_procedure_new_return_values (procedure,
|
|
|
|
GIMP_PDB_EXECUTION_ERROR,
|
|
|
|
NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2019-08-31 20:42:33 +08:00
|
|
|
return gimp_procedure_new_return_values (procedure, GIMP_PDB_SUCCESS, NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-08-18 20:17:21 +08:00
|
|
|
drawable_to_cmap (control_point *cp)
|
1999-12-27 22:14:53 +08:00
|
|
|
{
|
2019-06-28 18:37:26 +08:00
|
|
|
gint i, j;
|
2000-04-01 23:48:48 +08:00
|
|
|
|
2019-08-31 20:42:33 +08:00
|
|
|
if (TABLE_DRAWABLE >= config.cmap_drawable_id)
|
2000-04-01 23:48:48 +08:00
|
|
|
{
|
2019-08-31 20:42:33 +08:00
|
|
|
i = TABLE_DRAWABLE - config.cmap_drawable_id;
|
2000-04-01 23:48:48 +08:00
|
|
|
get_cmap (i, cp->cmap, 256);
|
|
|
|
}
|
2019-08-31 20:42:33 +08:00
|
|
|
else if (BLACK_DRAWABLE == config.cmap_drawable_id)
|
2000-04-01 23:48:48 +08:00
|
|
|
{
|
|
|
|
for (i = 0; i < 256; i++)
|
2004-11-05 19:35:38 +08:00
|
|
|
for (j = 0; j < 3; j++)
|
|
|
|
cp->cmap[i][j] = 0.0;
|
2000-04-01 23:48:48 +08:00
|
|
|
}
|
2019-08-31 20:42:33 +08:00
|
|
|
else if (GRADIENT_DRAWABLE == config.cmap_drawable_id)
|
2000-04-01 23:48:48 +08:00
|
|
|
{
|
2022-09-06 07:28:35 +08:00
|
|
|
GimpGradient *gradient = gimp_context_get_gradient ();
|
|
|
|
|
2004-10-06 07:28:17 +08:00
|
|
|
gint num;
|
|
|
|
gdouble *g;
|
|
|
|
|
2009-07-20 17:53:02 +08:00
|
|
|
/* FIXME: "reverse" hardcoded to FALSE. */
|
2022-09-06 07:28:35 +08:00
|
|
|
gimp_gradient_get_uniform_samples (gradient, 256, FALSE,
|
2004-10-06 07:28:17 +08:00
|
|
|
&num, &g);
|
|
|
|
|
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
for (i = 0; i < 256; i++)
|
2004-11-05 19:35:38 +08:00
|
|
|
for (j = 0; j < 3; j++)
|
|
|
|
cp->cmap[i][j] = g[i*4 + j];
|
2000-04-01 23:48:48 +08:00
|
|
|
g_free (g);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-09-03 16:48:32 +08:00
|
|
|
GimpDrawable *drawable = gimp_drawable_get_by_id (config.cmap_drawable_id);
|
2019-08-31 00:00:44 +08:00
|
|
|
GeglBuffer *buffer = gimp_drawable_get_buffer (drawable);
|
|
|
|
gint width = gegl_buffer_get_width (buffer);
|
|
|
|
gint height = gegl_buffer_get_height (buffer);
|
|
|
|
guchar p[3];
|
2019-06-28 18:37:26 +08:00
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
for (i = 0; i < 256; i++)
|
2004-11-05 19:35:38 +08:00
|
|
|
{
|
2019-06-28 18:37:26 +08:00
|
|
|
gegl_buffer_sample (buffer,
|
|
|
|
i % width,
|
|
|
|
(i / width) % height,
|
2019-08-31 00:00:44 +08:00
|
|
|
NULL, p, babl_format ("R'G'B' u8"),
|
2019-06-28 18:37:26 +08:00
|
|
|
GEGL_SAMPLER_NEAREST, GEGL_ABYSS_NONE);
|
|
|
|
|
2004-11-05 19:35:38 +08:00
|
|
|
for (j = 0; j < 3; j++)
|
2019-06-28 18:37:26 +08:00
|
|
|
cp->cmap[i][j] = p[j] / 255.0;
|
2004-11-05 19:35:38 +08:00
|
|
|
}
|
2019-06-28 18:37:26 +08:00
|
|
|
|
|
|
|
g_object_unref (buffer);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-08-18 20:17:21 +08:00
|
|
|
static void
|
2019-08-31 00:00:44 +08:00
|
|
|
flame (GimpDrawable *drawable)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2019-06-28 18:37:26 +08:00
|
|
|
const Babl *format;
|
|
|
|
gint width, height;
|
|
|
|
guchar *tmp;
|
|
|
|
gint bytes;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2021-04-06 20:28:40 +08:00
|
|
|
width = gimp_drawable_get_width (drawable);
|
|
|
|
height = gimp_drawable_get_height (drawable);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2019-08-31 00:00:44 +08:00
|
|
|
if (gimp_drawable_has_alpha (drawable))
|
2019-06-28 18:37:26 +08:00
|
|
|
format = babl_format ("R'G'B'A u8");
|
|
|
|
else
|
|
|
|
format = babl_format ("R'G'B' u8");
|
|
|
|
|
|
|
|
bytes = babl_format_get_bytes_per_pixel (format);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
tmp = g_new (guchar, width * height * 4);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* render */
|
|
|
|
config.cp.width = width;
|
|
|
|
config.cp.height = height;
|
|
|
|
if (config.randomize)
|
2000-04-01 23:48:48 +08:00
|
|
|
random_control_point (&config.cp, config.variation);
|
|
|
|
drawable_to_cmap (&config.cp);
|
|
|
|
render_rectangle (&f, tmp, width, field_both, 4,
|
2004-11-05 19:35:38 +08:00
|
|
|
gimp_progress_update);
|
2011-04-11 01:05:08 +08:00
|
|
|
gimp_progress_update (1.0);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* update destination */
|
2019-06-28 18:37:26 +08:00
|
|
|
if (bytes == 4)
|
2000-04-01 23:48:48 +08:00
|
|
|
{
|
2019-08-31 00:00:44 +08:00
|
|
|
GeglBuffer *buffer = gimp_drawable_get_shadow_buffer (drawable);
|
2019-06-28 18:37:26 +08:00
|
|
|
|
|
|
|
gegl_buffer_set (buffer, GEGL_RECTANGLE (0, 0, width, height), 0,
|
|
|
|
format, tmp,
|
|
|
|
GEGL_AUTO_ROWSTRIDE);
|
|
|
|
|
|
|
|
g_object_unref (buffer);
|
2000-04-01 23:48:48 +08:00
|
|
|
}
|
2019-06-28 18:37:26 +08:00
|
|
|
else if (bytes == 3)
|
2000-04-01 23:48:48 +08:00
|
|
|
{
|
2019-08-31 00:00:44 +08:00
|
|
|
GeglBuffer *src_buffer = gimp_drawable_get_buffer (drawable);
|
|
|
|
GeglBuffer *dest_buffer = gimp_drawable_get_shadow_buffer (drawable);
|
2019-06-28 18:37:26 +08:00
|
|
|
gint i, j;
|
|
|
|
guchar *sl;
|
2000-04-01 23:48:48 +08:00
|
|
|
|
|
|
|
sl = g_new (guchar, 3 * width);
|
|
|
|
|
|
|
|
for (i = 0; i < height; i++)
|
2004-11-05 19:35:38 +08:00
|
|
|
{
|
|
|
|
guchar *rr = tmp + 4 * i * width;
|
|
|
|
guchar *sld = sl;
|
|
|
|
|
2019-06-28 18:37:26 +08:00
|
|
|
gegl_buffer_get (src_buffer, GEGL_RECTANGLE (0, i, width, 1), 1.0,
|
|
|
|
format, sl,
|
|
|
|
GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
|
|
|
|
|
2004-11-05 19:35:38 +08:00
|
|
|
for (j = 0; j < width; j++)
|
|
|
|
{
|
|
|
|
gint k, alpha = rr[3];
|
|
|
|
|
|
|
|
for (k = 0; k < 3; k++)
|
|
|
|
{
|
|
|
|
gint t = (rr[k] + ((sld[k] * (256-alpha)) >> 8));
|
|
|
|
|
|
|
|
if (t > 255) t = 255;
|
|
|
|
sld[k] = t;
|
|
|
|
}
|
|
|
|
rr += 4;
|
|
|
|
sld += 3;
|
|
|
|
}
|
2019-06-28 18:37:26 +08:00
|
|
|
|
|
|
|
gegl_buffer_set (dest_buffer, GEGL_RECTANGLE (0, i, width, 1), 0,
|
|
|
|
format, sl,
|
|
|
|
GEGL_AUTO_ROWSTRIDE);
|
2004-11-05 19:35:38 +08:00
|
|
|
}
|
2019-06-28 18:37:26 +08:00
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
g_free (sl);
|
2019-06-28 18:37:26 +08:00
|
|
|
|
|
|
|
g_object_unref (src_buffer);
|
|
|
|
g_object_unref (dest_buffer);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
g_free (tmp);
|
2019-06-28 18:37:26 +08:00
|
|
|
|
2019-08-31 00:00:44 +08:00
|
|
|
gimp_drawable_merge_shadow (drawable, TRUE);
|
|
|
|
gimp_drawable_update (drawable, 0, 0, width, height);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-08-18 20:17:21 +08:00
|
|
|
static void
|
2004-04-16 00:58:21 +08:00
|
|
|
file_response_callback (GtkFileChooser *chooser,
|
|
|
|
gint response_id,
|
|
|
|
gpointer data)
|
1999-12-27 22:14:53 +08:00
|
|
|
{
|
2003-11-19 22:51:52 +08:00
|
|
|
if (response_id == GTK_RESPONSE_OK)
|
2000-04-01 23:48:48 +08:00
|
|
|
{
|
2004-04-16 00:58:21 +08:00
|
|
|
gchar *filename = gtk_file_chooser_get_filename (chooser);
|
2003-11-19 22:51:52 +08:00
|
|
|
|
|
|
|
if (load_save)
|
|
|
|
{
|
|
|
|
FILE *f;
|
|
|
|
gint i, c;
|
|
|
|
gchar *ss;
|
|
|
|
|
|
|
|
if (!g_file_test (filename, G_FILE_TEST_IS_REGULAR))
|
|
|
|
{
|
2004-01-19 11:06:04 +08:00
|
|
|
g_message (_("'%s' is not a regular file"),
|
|
|
|
gimp_filename_to_utf8 (filename));
|
2004-04-16 00:58:21 +08:00
|
|
|
g_free (filename);
|
2003-11-19 22:51:52 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-04-27 04:31:01 +08:00
|
|
|
f = g_fopen (filename, "rb");
|
2003-11-19 22:51:52 +08:00
|
|
|
|
|
|
|
if (f == NULL)
|
|
|
|
{
|
|
|
|
g_message (_("Could not open '%s' for reading: %s"),
|
2004-01-19 11:06:04 +08:00
|
|
|
gimp_filename_to_utf8 (filename), g_strerror (errno));
|
2004-04-16 00:58:21 +08:00
|
|
|
g_free (filename);
|
2003-11-19 22:51:52 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
ss = buffer;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
c = getc (f);
|
|
|
|
if (EOF == c)
|
|
|
|
break;
|
|
|
|
ss[i++] = c;
|
|
|
|
}
|
|
|
|
while (i < BUFFER_SIZE && ';' != c);
|
|
|
|
parse_control_point (&ss, &config.cp);
|
|
|
|
fclose (f);
|
|
|
|
/* i want to update the existing dialogue, but it's
|
|
|
|
too painful */
|
2022-11-01 01:57:14 +08:00
|
|
|
gimp_set_data (PLUG_IN_PROC, &config, sizeof (config));
|
2005-09-10 02:07:31 +08:00
|
|
|
/* gtk_widget_destroy(dialog); */
|
2003-11-19 22:51:52 +08:00
|
|
|
set_flame_preview ();
|
|
|
|
set_edit_preview ();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-04-27 04:31:01 +08:00
|
|
|
FILE *f = g_fopen (filename, "wb");
|
2003-11-19 22:51:52 +08:00
|
|
|
|
|
|
|
if (NULL == f)
|
|
|
|
{
|
|
|
|
g_message (_("Could not open '%s' for writing: %s"),
|
2004-01-19 11:06:04 +08:00
|
|
|
gimp_filename_to_utf8 (filename), g_strerror (errno));
|
2004-04-16 00:58:21 +08:00
|
|
|
g_free (filename);
|
2003-11-19 22:51:52 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
print_control_point (f, &config.cp, 0);
|
|
|
|
fclose (f);
|
|
|
|
}
|
2004-04-16 00:58:21 +08:00
|
|
|
|
|
|
|
g_free (filename);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2000-04-01 23:48:48 +08:00
|
|
|
|
2004-04-16 00:58:21 +08:00
|
|
|
gtk_widget_destroy (GTK_WIDGET (chooser));
|
2000-04-01 23:48:48 +08:00
|
|
|
|
2009-10-18 02:31:57 +08:00
|
|
|
if (! gtk_widget_get_sensitive (load_button))
|
2003-11-19 22:51:52 +08:00
|
|
|
gtk_widget_set_sensitive (load_button, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2009-10-18 02:31:57 +08:00
|
|
|
if (! gtk_widget_get_sensitive (save_button))
|
2003-11-19 22:51:52 +08:00
|
|
|
gtk_widget_set_sensitive (save_button, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1998-03-15 12:48:18 +08:00
|
|
|
static void
|
2005-09-10 02:07:31 +08:00
|
|
|
make_file_dialog (const gchar *title,
|
|
|
|
GtkWidget *parent)
|
1999-12-27 22:14:53 +08:00
|
|
|
{
|
2005-09-10 02:07:31 +08:00
|
|
|
file_dialog = gtk_file_chooser_dialog_new (title, GTK_WINDOW (parent),
|
|
|
|
load_save ?
|
|
|
|
GTK_FILE_CHOOSER_ACTION_OPEN :
|
|
|
|
GTK_FILE_CHOOSER_ACTION_SAVE,
|
2003-11-10 06:44:45 +08:00
|
|
|
|
2017-02-12 23:18:24 +08:00
|
|
|
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
2005-09-10 02:07:31 +08:00
|
|
|
load_save ?
|
2017-02-12 23:18:24 +08:00
|
|
|
_("_Open") : _("_Save"),
|
2005-09-10 02:07:31 +08:00
|
|
|
GTK_RESPONSE_OK,
|
2000-04-01 23:48:48 +08:00
|
|
|
|
2005-09-10 02:07:31 +08:00
|
|
|
NULL);
|
2004-04-16 00:58:21 +08:00
|
|
|
|
2017-02-12 23:18:24 +08:00
|
|
|
gtk_dialog_set_default_response (GTK_DIALOG (file_dialog), GTK_RESPONSE_OK);
|
2018-05-10 23:04:37 +08:00
|
|
|
gimp_dialog_set_alternative_button_order (GTK_DIALOG (file_dialog),
|
2005-04-08 01:10:05 +08:00
|
|
|
GTK_RESPONSE_OK,
|
|
|
|
GTK_RESPONSE_CANCEL,
|
|
|
|
-1);
|
2007-02-02 16:57:15 +08:00
|
|
|
|
|
|
|
if (! load_save)
|
|
|
|
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (file_dialog),
|
|
|
|
TRUE);
|
2005-04-08 01:10:05 +08:00
|
|
|
|
2005-09-10 02:07:31 +08:00
|
|
|
g_object_add_weak_pointer (G_OBJECT (file_dialog), (gpointer) &file_dialog);
|
2004-04-16 00:58:21 +08:00
|
|
|
|
2005-09-10 02:07:31 +08:00
|
|
|
gtk_window_set_destroy_with_parent (GTK_WINDOW (file_dialog), TRUE);
|
2003-11-19 22:51:52 +08:00
|
|
|
|
2005-09-10 02:07:31 +08:00
|
|
|
g_signal_connect (file_dialog, "delete-event",
|
2003-11-19 22:51:52 +08:00
|
|
|
G_CALLBACK (gtk_true),
|
|
|
|
NULL);
|
2005-09-10 02:07:31 +08:00
|
|
|
g_signal_connect (file_dialog, "response",
|
2003-11-19 22:51:52 +08:00
|
|
|
G_CALLBACK (file_response_callback),
|
|
|
|
NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-08-18 20:17:21 +08:00
|
|
|
static void
|
|
|
|
randomize_callback (GtkWidget *widget,
|
2004-11-05 19:35:38 +08:00
|
|
|
gpointer data)
|
1999-12-27 22:14:53 +08:00
|
|
|
{
|
2000-04-01 23:48:48 +08:00
|
|
|
random_control_point (&edit_cp, config.variation);
|
|
|
|
init_mutants ();
|
|
|
|
set_edit_preview ();
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-08-18 20:17:21 +08:00
|
|
|
static void
|
2003-11-06 23:27:05 +08:00
|
|
|
edit_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
|
|
|
gpointer data)
|
1999-12-27 22:14:53 +08:00
|
|
|
{
|
2003-11-06 23:27:05 +08:00
|
|
|
gtk_widget_hide (widget);
|
|
|
|
|
|
|
|
if (response_id == GTK_RESPONSE_OK)
|
|
|
|
{
|
|
|
|
config.cp = edit_cp;
|
|
|
|
set_flame_preview ();
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-08-18 20:17:21 +08:00
|
|
|
static void
|
2000-04-01 23:48:48 +08:00
|
|
|
init_mutants (void)
|
1999-12-27 22:14:53 +08:00
|
|
|
{
|
2000-04-01 23:48:48 +08:00
|
|
|
gint i;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
for (i = 0; i < NMUTANTS; i++)
|
|
|
|
{
|
|
|
|
mutants[i] = edit_cp;
|
|
|
|
random_control_point (mutants + i, config.variation);
|
|
|
|
if (VARIATION_SAME == config.variation)
|
2004-11-05 19:35:38 +08:00
|
|
|
copy_variation (mutants + i, &edit_cp);
|
2000-04-01 23:48:48 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-08-18 20:17:21 +08:00
|
|
|
static void
|
|
|
|
set_edit_preview (void)
|
1999-12-27 22:14:53 +08:00
|
|
|
{
|
2004-08-01 22:36:50 +08:00
|
|
|
gint i, j;
|
2000-04-01 23:48:48 +08:00
|
|
|
guchar *b;
|
|
|
|
control_point pcp;
|
|
|
|
gint nbytes = EDIT_PREVIEW_SIZE * EDIT_PREVIEW_SIZE * 3;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
static frame_spec pf = { 0.0, 0, 1, 0.0 };
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
if (NULL == edit_previews[0])
|
|
|
|
return;
|
|
|
|
|
|
|
|
b = g_new (guchar, nbytes);
|
|
|
|
maybe_init_cp ();
|
|
|
|
drawable_to_cmap (&edit_cp);
|
1997-11-25 06:05:25 +08:00
|
|
|
for (i = 0; i < 3; i++)
|
2000-04-01 23:48:48 +08:00
|
|
|
for (j = 0; j < 3; j++)
|
|
|
|
{
|
2004-11-05 19:35:38 +08:00
|
|
|
gint mut = i*3 + j;
|
|
|
|
|
|
|
|
pf.cps = &pcp;
|
|
|
|
if (1 == i && 1 == j)
|
|
|
|
{
|
|
|
|
pcp = edit_cp;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
control_point ends[2];
|
|
|
|
ends[0] = edit_cp;
|
|
|
|
ends[1] = mutants[mut];
|
|
|
|
ends[0].time = 0.0;
|
|
|
|
ends[1].time = 1.0;
|
|
|
|
interpolate (ends, 2, pick_speed, &pcp);
|
|
|
|
}
|
|
|
|
pcp.pixels_per_unit =
|
|
|
|
(pcp.pixels_per_unit * EDIT_PREVIEW_SIZE) / pcp.width;
|
|
|
|
pcp.width = EDIT_PREVIEW_SIZE;
|
|
|
|
pcp.height = EDIT_PREVIEW_SIZE;
|
|
|
|
|
|
|
|
pcp.sample_density = 1;
|
|
|
|
pcp.spatial_oversample = 1;
|
|
|
|
pcp.spatial_filter_radius = 0.5;
|
|
|
|
|
|
|
|
drawable_to_cmap (&pcp);
|
|
|
|
|
|
|
|
render_rectangle (&pf, b, EDIT_PREVIEW_SIZE, field_both, 3, NULL);
|
2000-04-01 23:48:48 +08:00
|
|
|
|
2004-08-01 22:36:50 +08:00
|
|
|
gimp_preview_area_draw (GIMP_PREVIEW_AREA (edit_previews[mut]),
|
|
|
|
0, 0, EDIT_PREVIEW_SIZE, EDIT_PREVIEW_SIZE,
|
|
|
|
GIMP_RGB_IMAGE,
|
|
|
|
b,
|
|
|
|
EDIT_PREVIEW_SIZE * 3);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2000-04-01 23:48:48 +08:00
|
|
|
g_free (b);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2004-11-05 19:35:38 +08:00
|
|
|
static void
|
2004-08-01 22:36:50 +08:00
|
|
|
edit_preview_size_allocate (GtkWidget *widget)
|
|
|
|
{
|
2004-11-05 19:35:38 +08:00
|
|
|
set_edit_preview ();
|
2004-08-01 22:36:50 +08:00
|
|
|
}
|
|
|
|
|
2003-08-18 20:17:21 +08:00
|
|
|
static void
|
|
|
|
preview_clicked (GtkWidget *widget,
|
2004-11-05 19:35:38 +08:00
|
|
|
gpointer data)
|
1999-12-27 22:14:53 +08:00
|
|
|
{
|
2003-01-06 04:38:21 +08:00
|
|
|
gint mut = GPOINTER_TO_INT (data);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
if (mut == 4)
|
|
|
|
{
|
|
|
|
control_point t = edit_cp;
|
|
|
|
init_mutants ();
|
|
|
|
edit_cp = t;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
control_point ends[2];
|
|
|
|
ends[0] = edit_cp;
|
|
|
|
ends[1] = mutants[mut];
|
|
|
|
ends[0].time = 0.0;
|
|
|
|
ends[1].time = 1.0;
|
|
|
|
interpolate (ends, 2, pick_speed, &edit_cp);
|
|
|
|
}
|
|
|
|
set_edit_preview ();
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-03-15 12:48:18 +08:00
|
|
|
static void
|
2003-08-18 20:17:21 +08:00
|
|
|
edit_callback (GtkWidget *widget,
|
2004-11-05 19:35:38 +08:00
|
|
|
GtkWidget *parent)
|
1999-12-27 22:14:53 +08:00
|
|
|
{
|
1997-11-25 06:05:25 +08:00
|
|
|
edit_cp = config.cp;
|
1999-12-27 22:14:53 +08:00
|
|
|
|
2005-09-10 02:07:31 +08:00
|
|
|
if (edit_dialog == NULL)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2020-10-31 07:53:26 +08:00
|
|
|
GtkWidget *main_vbox;
|
|
|
|
GtkWidget *frame;
|
|
|
|
GtkWidget *grid;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *button;
|
|
|
|
GtkWidget *combo;
|
|
|
|
GtkWidget *label;
|
|
|
|
GtkWidget *scale;
|
|
|
|
gint i, j;
|
2000-04-01 23:48:48 +08:00
|
|
|
|
2011-04-09 02:31:34 +08:00
|
|
|
edit_dialog = gimp_dialog_new (_("Edit Flame"), PLUG_IN_ROLE,
|
2005-09-10 02:07:31 +08:00
|
|
|
parent, GTK_DIALOG_DESTROY_WITH_PARENT,
|
|
|
|
gimp_standard_help_func, PLUG_IN_PROC,
|
2000-04-01 23:48:48 +08:00
|
|
|
|
2017-02-12 23:18:24 +08:00
|
|
|
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
|
|
|
_("_OK"), GTK_RESPONSE_OK,
|
2002-02-05 21:29:46 +08:00
|
|
|
|
2005-09-10 02:07:31 +08:00
|
|
|
NULL);
|
2000-04-01 23:48:48 +08:00
|
|
|
|
2018-05-10 23:04:37 +08:00
|
|
|
gimp_dialog_set_alternative_button_order (GTK_DIALOG (edit_dialog),
|
2005-08-15 19:09:18 +08:00
|
|
|
GTK_RESPONSE_OK,
|
|
|
|
GTK_RESPONSE_CANCEL,
|
|
|
|
-1);
|
2005-02-09 04:40:33 +08:00
|
|
|
|
2005-09-10 02:07:31 +08:00
|
|
|
g_signal_connect (edit_dialog, "response",
|
2003-11-06 23:27:05 +08:00
|
|
|
G_CALLBACK (edit_response),
|
2005-09-10 02:07:31 +08:00
|
|
|
edit_dialog);
|
2000-04-01 23:48:48 +08:00
|
|
|
|
2011-09-30 18:17:53 +08:00
|
|
|
main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
2004-05-20 23:51:25 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
|
2009-07-16 00:57:12 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (edit_dialog))),
|
|
|
|
main_vbox, FALSE, FALSE, 0);
|
2000-04-01 23:48:48 +08:00
|
|
|
|
2004-05-20 23:51:25 +08:00
|
|
|
frame = gimp_frame_new (_("Directions"));
|
2000-04-01 23:48:48 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
2018-05-08 21:45:17 +08:00
|
|
|
grid = gtk_grid_new ();
|
|
|
|
gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
|
|
|
|
gtk_grid_set_column_spacing (GTK_GRID (grid), 6);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), grid);
|
|
|
|
gtk_widget_show (grid);
|
2000-04-01 23:48:48 +08:00
|
|
|
|
|
|
|
for (i = 0; i < 3; i++)
|
2004-11-05 19:35:38 +08:00
|
|
|
for (j = 0; j < 3; j++)
|
|
|
|
{
|
|
|
|
gint mut = i * 3 + j;
|
2000-04-01 23:48:48 +08:00
|
|
|
|
2004-11-05 19:35:38 +08:00
|
|
|
edit_previews[mut] = gimp_preview_area_new ();
|
|
|
|
gtk_widget_set_size_request (edit_previews[mut],
|
2004-08-01 22:36:50 +08:00
|
|
|
EDIT_PREVIEW_SIZE,
|
|
|
|
EDIT_PREVIEW_SIZE);
|
2004-11-05 19:35:38 +08:00
|
|
|
button = gtk_button_new ();
|
2018-05-08 21:45:17 +08:00
|
|
|
gtk_widget_set_hexpand (button, TRUE);
|
|
|
|
gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
|
2004-11-05 19:35:38 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER(button), edit_previews[mut]);
|
2018-05-08 21:45:17 +08:00
|
|
|
gtk_grid_attach (GTK_GRID (grid), button, i, j, 1, 1);
|
2004-11-05 19:35:38 +08:00
|
|
|
gtk_widget_show (edit_previews[mut]);
|
2004-08-01 22:36:50 +08:00
|
|
|
|
2004-11-05 19:35:38 +08:00
|
|
|
gtk_widget_show (button);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2004-11-05 19:35:38 +08:00
|
|
|
g_signal_connect (button, "clicked",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (preview_clicked),
|
|
|
|
GINT_TO_POINTER (mut));
|
2004-11-05 19:35:38 +08:00
|
|
|
}
|
|
|
|
|
2004-08-01 22:36:50 +08:00
|
|
|
g_signal_connect (edit_previews[0], "size-allocate",
|
2004-11-05 19:35:38 +08:00
|
|
|
G_CALLBACK (edit_preview_size_allocate),
|
|
|
|
NULL);
|
2000-04-01 23:48:48 +08:00
|
|
|
|
2004-11-05 19:35:38 +08:00
|
|
|
frame = gimp_frame_new (_("Controls"));
|
2000-04-01 23:48:48 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
2011-09-30 18:17:53 +08:00
|
|
|
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
|
2000-04-01 23:48:48 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
|
|
|
gtk_widget_show (vbox);
|
|
|
|
|
2020-11-01 09:35:03 +08:00
|
|
|
scale = gimp_scale_entry_new (_("_Speed:"), pick_speed, 0.05, 0.5, 2);
|
2020-11-06 00:37:15 +08:00
|
|
|
gimp_label_spin_set_increments (GIMP_LABEL_SPIN (scale), 0.01, 0.1);
|
2020-10-31 07:53:26 +08:00
|
|
|
|
|
|
|
g_signal_connect (scale, "value-changed",
|
|
|
|
G_CALLBACK (flame_scale_entry_update_double),
|
2001-12-29 21:26:29 +08:00
|
|
|
&pick_speed);
|
2020-10-31 07:53:26 +08:00
|
|
|
g_signal_connect (scale, "value-changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (set_edit_preview),
|
|
|
|
NULL);
|
2020-10-31 07:53:26 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 6);
|
|
|
|
gtk_widget_show (scale);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2011-09-30 18:17:53 +08:00
|
|
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
2000-04-01 23:48:48 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
2002-06-03 03:55:30 +08:00
|
|
|
button = gtk_button_new_with_mnemonic( _("_Randomize"));
|
2018-04-29 07:51:36 +08:00
|
|
|
g_object_set (gtk_bin_get_child (GTK_BIN (button)),
|
|
|
|
"margin-start", 2,
|
|
|
|
"margin-end", 2,
|
|
|
|
NULL);
|
2000-04-01 23:48:48 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect_swapped (button, "clicked",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (randomize_callback),
|
|
|
|
NULL);
|
|
|
|
|
2008-04-26 15:18:15 +08:00
|
|
|
combo = gimp_int_combo_box_new (_("Same"), VARIATION_SAME,
|
|
|
|
_("Random"), variation_random,
|
|
|
|
_("Linear"), 0,
|
|
|
|
_("Sinusoidal"), 1,
|
|
|
|
_("Spherical"), 2,
|
|
|
|
_("Swirl"), 3,
|
|
|
|
_("Horseshoe"), 4,
|
|
|
|
_("Polar"), 5,
|
|
|
|
_("Bent"), 6,
|
|
|
|
_("Handkerchief"), 7,
|
|
|
|
_("Heart"), 8,
|
|
|
|
_("Disc"), 9,
|
|
|
|
_("Spiral"), 10,
|
|
|
|
_("Hyperbolic"), 11,
|
|
|
|
_("Diamond"), 12,
|
|
|
|
_("Ex"), 13,
|
|
|
|
_("Julia"), 14,
|
|
|
|
_("Waves"), 15,
|
|
|
|
_("Fisheye"), 16,
|
|
|
|
_("Popcorn"), 17,
|
|
|
|
_("Exponential"), 18,
|
|
|
|
_("Power"), 19,
|
|
|
|
_("Cosine"), 20,
|
|
|
|
_("Rings"), 21,
|
|
|
|
_("Fan"), 22,
|
|
|
|
_("Eyefish"), 23,
|
|
|
|
_("Bubble"), 24,
|
|
|
|
_("Cylinder"), 25,
|
|
|
|
_("Noise"), 26,
|
|
|
|
_("Blur"), 27,
|
|
|
|
_("Gaussian"), 28,
|
2004-04-20 20:21:17 +08:00
|
|
|
NULL);
|
2003-11-15 02:05:39 +08:00
|
|
|
|
2004-04-20 20:21:17 +08:00
|
|
|
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (combo),
|
|
|
|
VARIATION_SAME);
|
2003-11-15 02:05:39 +08:00
|
|
|
|
2004-04-20 20:21:17 +08:00
|
|
|
g_signal_connect (combo, "changed",
|
|
|
|
G_CALLBACK (combo_callback),
|
|
|
|
&config.variation);
|
|
|
|
|
2004-05-20 23:51:25 +08:00
|
|
|
gtk_box_pack_end (GTK_BOX (hbox), combo, TRUE, TRUE, 0);
|
2004-04-20 20:21:17 +08:00
|
|
|
gtk_widget_show (combo);
|
2000-04-01 23:48:48 +08:00
|
|
|
|
2002-06-03 03:55:30 +08:00
|
|
|
label = gtk_label_new_with_mnemonic (_("_Variation:"));
|
2000-04-01 23:48:48 +08:00
|
|
|
gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
2004-04-20 20:21:17 +08:00
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
|
2000-04-01 23:48:48 +08:00
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
gtk_widget_show (main_vbox);
|
|
|
|
|
|
|
|
init_mutants ();
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
set_edit_preview ();
|
|
|
|
|
2005-09-10 02:07:31 +08:00
|
|
|
gtk_window_present (GTK_WINDOW (edit_dialog));
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-08-18 20:17:21 +08:00
|
|
|
static void
|
|
|
|
load_callback (GtkWidget *widget,
|
2004-11-05 19:35:38 +08:00
|
|
|
gpointer data)
|
1999-12-27 22:14:53 +08:00
|
|
|
{
|
2005-09-10 02:07:31 +08:00
|
|
|
if (! file_dialog)
|
2000-04-01 23:48:48 +08:00
|
|
|
{
|
2004-04-16 00:58:21 +08:00
|
|
|
load_save = 1;
|
2005-09-10 02:07:31 +08:00
|
|
|
make_file_dialog (_("Load Flame"), gtk_widget_get_toplevel (widget));
|
2004-04-16 00:58:21 +08:00
|
|
|
|
|
|
|
gtk_widget_set_sensitive (save_button, FALSE);
|
2000-04-01 23:48:48 +08:00
|
|
|
}
|
2004-04-16 00:58:21 +08:00
|
|
|
|
2005-09-10 02:07:31 +08:00
|
|
|
gtk_window_present (GTK_WINDOW (file_dialog));
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-08-18 20:17:21 +08:00
|
|
|
static void
|
|
|
|
save_callback (GtkWidget *widget,
|
2004-11-05 19:35:38 +08:00
|
|
|
gpointer data)
|
1999-12-27 22:14:53 +08:00
|
|
|
{
|
2005-09-10 02:07:31 +08:00
|
|
|
if (! file_dialog)
|
2000-04-01 23:48:48 +08:00
|
|
|
{
|
2004-04-16 00:58:21 +08:00
|
|
|
load_save = 0;
|
2005-09-10 02:07:31 +08:00
|
|
|
make_file_dialog (_("Save Flame"), gtk_widget_get_toplevel (widget));
|
2004-04-16 00:58:21 +08:00
|
|
|
|
|
|
|
gtk_widget_set_sensitive (load_button, FALSE);
|
2000-04-01 23:48:48 +08:00
|
|
|
}
|
2004-04-16 00:58:21 +08:00
|
|
|
|
2005-09-10 02:07:31 +08:00
|
|
|
gtk_window_present (GTK_WINDOW (file_dialog));
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-08-18 20:17:21 +08:00
|
|
|
static void
|
2004-04-20 20:21:17 +08:00
|
|
|
combo_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1999-12-27 22:14:53 +08:00
|
|
|
{
|
2004-04-20 20:21:17 +08:00
|
|
|
gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), (gint *) data);
|
2000-04-01 23:48:48 +08:00
|
|
|
|
|
|
|
if (VARIATION_SAME != config.variation)
|
|
|
|
random_control_point (&edit_cp, config.variation);
|
2004-04-20 20:21:17 +08:00
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
init_mutants ();
|
|
|
|
set_edit_preview ();
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-08-18 20:17:21 +08:00
|
|
|
static void
|
|
|
|
set_flame_preview (void)
|
1999-12-27 22:14:53 +08:00
|
|
|
{
|
1997-11-25 06:05:25 +08:00
|
|
|
guchar *b;
|
|
|
|
control_point pcp;
|
2000-04-01 23:48:48 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
static frame_spec pf = {0.0, 0, 1, 0.0};
|
|
|
|
|
|
|
|
if (NULL == flame_preview)
|
|
|
|
return;
|
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
b = g_new (guchar, preview_width * preview_height * 3);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
maybe_init_cp ();
|
|
|
|
drawable_to_cmap (&config.cp);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
pf.cps = &pcp;
|
|
|
|
pcp = config.cp;
|
|
|
|
pcp.pixels_per_unit =
|
|
|
|
(pcp.pixels_per_unit * preview_width) / pcp.width;
|
|
|
|
pcp.width = preview_width;
|
|
|
|
pcp.height = preview_height;
|
|
|
|
pcp.sample_density = 1;
|
|
|
|
pcp.spatial_oversample = 1;
|
|
|
|
pcp.spatial_filter_radius = 0.1;
|
2000-04-01 23:48:48 +08:00
|
|
|
render_rectangle (&pf, b, preview_width, field_both, 3, NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-08-01 22:36:50 +08:00
|
|
|
gimp_preview_area_draw (GIMP_PREVIEW_AREA (flame_preview),
|
|
|
|
0, 0, preview_width, PREVIEW_SIZE,
|
|
|
|
GIMP_RGB_IMAGE,
|
|
|
|
b,
|
|
|
|
preview_width * 3);
|
2000-04-01 23:48:48 +08:00
|
|
|
g_free (b);
|
2004-08-01 22:36:50 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-08-01 22:36:50 +08:00
|
|
|
static void
|
|
|
|
flame_preview_size_allocate (GtkWidget *preview)
|
|
|
|
{
|
2004-11-05 19:35:38 +08:00
|
|
|
set_flame_preview ();
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-08-18 20:17:21 +08:00
|
|
|
static void
|
|
|
|
set_cmap_preview (void)
|
1999-12-27 22:14:53 +08:00
|
|
|
{
|
2000-04-01 23:48:48 +08:00
|
|
|
gint i, x, y;
|
1997-11-25 06:05:25 +08:00
|
|
|
guchar b[96];
|
2004-08-01 22:36:50 +08:00
|
|
|
guchar *cmap_buffer, *ptr;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (NULL == cmap_preview)
|
|
|
|
return;
|
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
drawable_to_cmap (&config.cp);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-11-05 19:35:38 +08:00
|
|
|
cmap_buffer = g_new (guchar, 32*32*3);
|
2004-08-01 22:36:50 +08:00
|
|
|
ptr = cmap_buffer;
|
2000-04-01 23:48:48 +08:00
|
|
|
for (y = 0; y < 32; y += 4)
|
|
|
|
{
|
|
|
|
for (x = 0; x < 32; x++)
|
2004-11-05 19:35:38 +08:00
|
|
|
{
|
|
|
|
gint j;
|
2000-04-01 23:48:48 +08:00
|
|
|
|
2004-11-05 19:35:38 +08:00
|
|
|
i = x + (y/4) * 32;
|
|
|
|
for (j = 0; j < 3; j++)
|
|
|
|
b[x*3+j] = config.cp.cmap[i][j]*255.0;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-08-01 22:36:50 +08:00
|
|
|
memcpy (ptr, b, 32*3);
|
|
|
|
ptr += 32*3;
|
|
|
|
memcpy (ptr, b, 32*3);
|
|
|
|
ptr += 32*3;
|
|
|
|
memcpy (ptr, b, 32*3);
|
|
|
|
ptr += 32*3;
|
|
|
|
memcpy (ptr, b, 32*3);
|
|
|
|
ptr += 32*3;
|
2004-11-05 19:35:38 +08:00
|
|
|
}
|
|
|
|
|
2004-08-01 22:36:50 +08:00
|
|
|
gimp_preview_area_draw (GIMP_PREVIEW_AREA (cmap_preview),
|
|
|
|
0, 0, 32, 32,
|
|
|
|
GIMP_RGB_IMAGE,
|
|
|
|
cmap_buffer,
|
2004-11-05 19:35:38 +08:00
|
|
|
32 * 3);
|
2004-08-01 22:36:50 +08:00
|
|
|
g_free (cmap_buffer);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-08-18 20:17:21 +08:00
|
|
|
static void
|
2004-04-22 07:09:16 +08:00
|
|
|
cmap_callback (GtkWidget *widget,
|
2004-11-05 19:35:38 +08:00
|
|
|
gpointer data)
|
1999-12-27 22:14:53 +08:00
|
|
|
{
|
2004-04-22 07:09:16 +08:00
|
|
|
gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget),
|
2019-08-31 20:42:33 +08:00
|
|
|
&config.cmap_drawable_id);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-04-22 07:09:16 +08:00
|
|
|
set_cmap_preview ();
|
|
|
|
set_flame_preview ();
|
1997-11-25 06:05:25 +08:00
|
|
|
/* set_edit_preview(); */
|
|
|
|
}
|
|
|
|
|
2004-04-22 07:09:16 +08:00
|
|
|
static gboolean
|
2019-08-31 00:00:44 +08:00
|
|
|
cmap_constrain (GimpImage *image,
|
|
|
|
GimpItem *item,
|
|
|
|
gpointer data)
|
2003-08-18 20:17:21 +08:00
|
|
|
{
|
2019-08-31 00:00:44 +08:00
|
|
|
return ! item || ! gimp_drawable_is_indexed (GIMP_DRAWABLE (item));
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-05-20 23:51:25 +08:00
|
|
|
static gboolean
|
2005-09-10 02:07:31 +08:00
|
|
|
flame_dialog (void)
|
1999-12-27 22:14:53 +08:00
|
|
|
{
|
2020-10-31 07:53:26 +08:00
|
|
|
GtkWidget *main_vbox;
|
|
|
|
GtkWidget *notebook;
|
|
|
|
GtkWidget *label;
|
|
|
|
GtkWidget *frame;
|
|
|
|
GtkWidget *button;
|
|
|
|
GtkWidget *grid;
|
|
|
|
GtkWidget *box;
|
|
|
|
GtkWidget *scale;
|
|
|
|
gboolean run;
|
2000-05-01 02:17:55 +08:00
|
|
|
|
2019-09-21 01:39:00 +08:00
|
|
|
gimp_ui_init (PLUG_IN_BINARY);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2011-04-09 02:31:34 +08:00
|
|
|
dialog = gimp_dialog_new (_("Flame"), PLUG_IN_ROLE,
|
2005-09-10 02:07:31 +08:00
|
|
|
NULL, 0,
|
|
|
|
gimp_standard_help_func, PLUG_IN_PROC,
|
2000-04-01 23:48:48 +08:00
|
|
|
|
2017-02-12 23:18:24 +08:00
|
|
|
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
|
|
|
_("_OK"), GTK_RESPONSE_OK,
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2005-09-10 02:07:31 +08:00
|
|
|
NULL);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2018-05-10 23:04:37 +08:00
|
|
|
gimp_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
|
2005-08-15 19:09:18 +08:00
|
|
|
GTK_RESPONSE_OK,
|
|
|
|
GTK_RESPONSE_CANCEL,
|
|
|
|
-1);
|
2005-02-09 04:40:33 +08:00
|
|
|
|
2005-09-10 02:07:31 +08:00
|
|
|
gimp_window_set_transient (GTK_WINDOW (dialog));
|
2005-09-06 05:40:29 +08:00
|
|
|
|
2011-09-30 18:17:53 +08:00
|
|
|
main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
2004-05-20 23:51:25 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
|
2009-07-16 00:57:12 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
|
|
|
|
main_vbox, FALSE, FALSE, 0);
|
2000-04-01 23:48:48 +08:00
|
|
|
gtk_widget_show (main_vbox);
|
|
|
|
|
2011-09-30 18:17:53 +08:00
|
|
|
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
|
2000-04-01 23:48:48 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), box, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (box);
|
|
|
|
|
2004-05-20 23:51:25 +08:00
|
|
|
frame = gtk_frame_new (NULL);
|
2018-10-22 20:47:54 +08:00
|
|
|
gtk_widget_set_valign (frame, GTK_ALIGN_START);
|
2004-05-20 23:51:25 +08:00
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
2018-10-22 20:47:54 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (box), frame, FALSE, FALSE, 0);
|
2000-04-01 23:48:48 +08:00
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
2004-08-01 22:36:50 +08:00
|
|
|
flame_preview = gimp_preview_area_new ();
|
2000-04-01 23:48:48 +08:00
|
|
|
{
|
2004-05-20 23:51:25 +08:00
|
|
|
gdouble aspect = config.cp.width / (double) config.cp.height;
|
|
|
|
|
|
|
|
if (aspect > 1.0)
|
|
|
|
{
|
2004-11-05 19:35:38 +08:00
|
|
|
preview_width = PREVIEW_SIZE;
|
|
|
|
preview_height = PREVIEW_SIZE / aspect;
|
2004-05-20 23:51:25 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-11-05 19:35:38 +08:00
|
|
|
preview_width = PREVIEW_SIZE * aspect;
|
|
|
|
preview_height = PREVIEW_SIZE;
|
2004-05-20 23:51:25 +08:00
|
|
|
}
|
|
|
|
}
|
2004-08-01 22:36:50 +08:00
|
|
|
gtk_widget_set_size_request (flame_preview, preview_width, preview_height);
|
2004-05-20 23:51:25 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (frame), flame_preview);
|
|
|
|
gtk_widget_show (flame_preview);
|
2004-08-01 22:36:50 +08:00
|
|
|
g_signal_connect (flame_preview, "size-allocate",
|
|
|
|
G_CALLBACK (flame_preview_size_allocate), NULL);
|
2004-05-20 23:51:25 +08:00
|
|
|
|
|
|
|
{
|
|
|
|
GtkWidget *vbox;
|
2000-04-01 23:48:48 +08:00
|
|
|
GtkWidget *vbbox;
|
|
|
|
|
2011-09-30 18:17:53 +08:00
|
|
|
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
|
2004-05-20 23:51:25 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (box), vbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (vbox);
|
2000-04-01 23:48:48 +08:00
|
|
|
|
2011-09-30 21:43:02 +08:00
|
|
|
vbbox= gtk_button_box_new (GTK_ORIENTATION_VERTICAL);
|
2000-04-01 23:48:48 +08:00
|
|
|
gtk_box_set_homogeneous (GTK_BOX (vbbox), FALSE);
|
2004-05-20 23:51:25 +08:00
|
|
|
gtk_box_set_spacing (GTK_BOX (vbbox), 6);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), vbbox, FALSE, FALSE, 0);
|
2000-04-01 23:48:48 +08:00
|
|
|
gtk_widget_show (vbbox);
|
2003-08-18 20:17:21 +08:00
|
|
|
|
2017-03-05 23:01:59 +08:00
|
|
|
button = gtk_button_new_with_mnemonic (_("_Edit"));
|
2000-04-01 23:48:48 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbbox), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (button, "clicked",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (edit_callback),
|
2005-09-10 02:07:31 +08:00
|
|
|
dialog);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2017-03-05 23:01:59 +08:00
|
|
|
load_button = button = gtk_button_new_with_mnemonic (_("_Open"));
|
2000-04-01 23:48:48 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbbox), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (button, "clicked",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (load_callback),
|
|
|
|
NULL);
|
|
|
|
|
2017-03-05 23:01:59 +08:00
|
|
|
save_button = button = gtk_button_new_with_mnemonic (_("_Save"));
|
2000-04-01 23:48:48 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbbox), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (button);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (button, "clicked",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (save_callback),
|
|
|
|
NULL);
|
2000-04-01 23:48:48 +08:00
|
|
|
}
|
|
|
|
|
2002-06-03 03:55:30 +08:00
|
|
|
notebook = gtk_notebook_new ();
|
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), notebook, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (notebook);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2011-09-30 18:17:53 +08:00
|
|
|
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
2004-05-20 23:51:25 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (box), 12);
|
2002-06-03 03:55:30 +08:00
|
|
|
label = gtk_label_new_with_mnemonic(_("_Rendering"));
|
|
|
|
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), box, label);
|
2000-04-01 23:48:48 +08:00
|
|
|
gtk_widget_show (box);
|
|
|
|
|
2018-05-08 21:45:17 +08:00
|
|
|
grid = gtk_grid_new ();
|
|
|
|
gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
|
|
|
|
gtk_grid_set_column_spacing (GTK_GRID (grid), 6);
|
|
|
|
gtk_box_pack_start (GTK_BOX (box), grid, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (grid);
|
2000-04-01 23:48:48 +08:00
|
|
|
|
2020-11-01 09:35:03 +08:00
|
|
|
scale = gimp_scale_entry_new (_("_Brightness:"), config.cp.brightness, 0, 5, 2);
|
2020-11-06 00:37:15 +08:00
|
|
|
gimp_label_spin_set_increments (GIMP_LABEL_SPIN (scale), 0.1, 1.0);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2020-10-31 07:53:26 +08:00
|
|
|
g_signal_connect (scale, "value-changed",
|
|
|
|
G_CALLBACK (flame_scale_entry_update_double),
|
2001-12-29 21:26:29 +08:00
|
|
|
&config.cp.brightness);
|
2020-10-31 07:53:26 +08:00
|
|
|
g_signal_connect (scale, "value-changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (set_flame_preview),
|
|
|
|
NULL);
|
2020-10-31 07:53:26 +08:00
|
|
|
gtk_grid_attach (GTK_GRID (grid), scale, 0, 0, 3, 1);
|
|
|
|
gtk_widget_show (scale);
|
2000-04-01 23:48:48 +08:00
|
|
|
|
2020-11-01 09:35:03 +08:00
|
|
|
scale = gimp_scale_entry_new (_("Co_ntrast:"), config.cp.contrast, 0, 5, 2);
|
2020-11-06 00:37:15 +08:00
|
|
|
gimp_label_spin_set_increments (GIMP_LABEL_SPIN (scale), 0.1, 1.0);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2020-10-31 07:53:26 +08:00
|
|
|
g_signal_connect (scale, "value-changed",
|
|
|
|
G_CALLBACK (flame_scale_entry_update_double),
|
2001-12-29 21:26:29 +08:00
|
|
|
&config.cp.contrast);
|
2020-10-31 07:53:26 +08:00
|
|
|
g_signal_connect (scale, "value-changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (set_flame_preview),
|
|
|
|
NULL);
|
2020-10-31 07:53:26 +08:00
|
|
|
gtk_grid_attach (GTK_GRID (grid), scale, 0, 1, 3, 1);
|
|
|
|
gtk_widget_show (scale);
|
2000-04-01 23:48:48 +08:00
|
|
|
|
2020-11-01 09:35:03 +08:00
|
|
|
scale = gimp_scale_entry_new (_("_Gamma:"), config.cp.gamma, 1, 5, 2);
|
2020-11-06 00:37:15 +08:00
|
|
|
gimp_label_spin_set_increments (GIMP_LABEL_SPIN (scale), 0.1, 1.0);
|
|
|
|
gtk_widget_set_margin_bottom (gimp_labeled_get_label (GIMP_LABELED (scale)), 6);
|
|
|
|
gtk_widget_set_margin_bottom (gimp_scale_entry_get_range (GIMP_SCALE_ENTRY (scale)), 6);
|
|
|
|
gtk_widget_set_margin_bottom (gimp_label_spin_get_spin_button (GIMP_LABEL_SPIN (scale)), 6);
|
2020-10-31 07:53:26 +08:00
|
|
|
|
|
|
|
g_signal_connect (scale, "value-changed",
|
|
|
|
G_CALLBACK (flame_scale_entry_update_double),
|
2001-12-29 21:26:29 +08:00
|
|
|
&config.cp.gamma);
|
2020-10-31 07:53:26 +08:00
|
|
|
g_signal_connect (scale, "value-changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (set_flame_preview),
|
|
|
|
NULL);
|
2020-10-31 07:53:26 +08:00
|
|
|
gtk_grid_attach (GTK_GRID (grid), scale, 0, 2, 3, 1);
|
|
|
|
gtk_widget_show (scale);
|
2000-04-01 23:48:48 +08:00
|
|
|
|
2020-11-01 09:35:03 +08:00
|
|
|
scale = gimp_scale_entry_new (_("Sample _density:"), config.cp.sample_density, 0.1, 20, 2);
|
2020-11-06 00:37:15 +08:00
|
|
|
gimp_label_spin_set_increments (GIMP_LABEL_SPIN (scale), 0.1, 5.0);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2020-10-31 07:53:26 +08:00
|
|
|
g_signal_connect (scale, "value-changed",
|
|
|
|
G_CALLBACK (flame_scale_entry_update_double),
|
2001-12-29 21:26:29 +08:00
|
|
|
&config.cp.sample_density);
|
2020-10-31 07:53:26 +08:00
|
|
|
gtk_grid_attach (GTK_GRID (grid), scale, 0, 3, 3, 1);
|
|
|
|
gtk_widget_show (scale);
|
2000-04-01 23:48:48 +08:00
|
|
|
|
2020-11-01 09:35:03 +08:00
|
|
|
scale = gimp_scale_entry_new (_("Spa_tial oversample:"), config.cp.spatial_oversample, 1, 4, 0);
|
2020-11-06 00:37:15 +08:00
|
|
|
gimp_label_spin_set_increments (GIMP_LABEL_SPIN (scale), 0.01, 0.1);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2020-10-31 07:53:26 +08:00
|
|
|
g_signal_connect (scale, "value-changed",
|
|
|
|
G_CALLBACK (flame_scale_entry_update_int),
|
2001-12-29 21:26:29 +08:00
|
|
|
&config.cp.spatial_oversample);
|
2020-10-31 07:53:26 +08:00
|
|
|
gtk_grid_attach (GTK_GRID (grid), scale, 0, 4, 3, 1);
|
|
|
|
gtk_widget_show (scale);
|
2000-04-01 23:48:48 +08:00
|
|
|
|
2020-11-01 09:35:03 +08:00
|
|
|
scale = gimp_scale_entry_new (_("Spatial _filter radius:"), config.cp.spatial_filter_radius, 0, 4, 2);
|
2020-11-06 00:37:15 +08:00
|
|
|
gimp_label_spin_set_increments (GIMP_LABEL_SPIN (scale), 0.2, 1.0);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2020-10-31 07:53:26 +08:00
|
|
|
g_signal_connect (scale, "value-changed",
|
|
|
|
G_CALLBACK (flame_scale_entry_update_double),
|
2001-12-29 21:26:29 +08:00
|
|
|
&config.cp.spatial_filter_radius);
|
2020-10-31 07:53:26 +08:00
|
|
|
gtk_grid_attach (GTK_GRID (grid), scale, 0, 5, 3, 1);
|
|
|
|
gtk_widget_show (scale);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
{
|
1997-11-25 06:05:25 +08:00
|
|
|
GtkWidget *hbox;
|
2000-04-01 23:48:48 +08:00
|
|
|
GtkWidget *label;
|
2004-04-22 07:09:16 +08:00
|
|
|
GtkWidget *combo;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2011-09-30 18:17:53 +08:00
|
|
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
2000-04-01 23:48:48 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (hbox);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-06-03 03:55:30 +08:00
|
|
|
label = gtk_label_new_with_mnemonic (_("Color_map:"));
|
2000-04-01 23:48:48 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (label);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2019-08-08 05:16:25 +08:00
|
|
|
combo = gimp_drawable_combo_box_new (cmap_constrain, NULL, NULL);
|
2004-04-22 07:09:16 +08:00
|
|
|
|
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
#if 0
|
2004-04-22 07:09:16 +08:00
|
|
|
gimp_int_combo_box_prepend (GIMP_INT_COMBO_BOX (combo),
|
|
|
|
GIMP_INT_STORE_VALUE, BLACK_DRAWABLE,
|
|
|
|
GIMP_INT_STORE_LABEL, _("Black"),
|
|
|
|
-1);
|
1997-11-25 06:05:25 +08:00
|
|
|
#endif
|
2004-04-22 07:09:16 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-04-22 07:09:16 +08:00
|
|
|
static const gchar *names[] =
|
2000-04-01 23:48:48 +08:00
|
|
|
{
|
2004-11-05 19:35:38 +08:00
|
|
|
"sunny harvest",
|
|
|
|
"rose",
|
|
|
|
"calcoast09",
|
|
|
|
"klee insula-dulcamara",
|
|
|
|
"ernst anti-pope",
|
|
|
|
"gris josette"
|
2000-04-01 23:48:48 +08:00
|
|
|
};
|
2004-04-22 07:09:16 +08:00
|
|
|
static const gint good[] = { 10, 20, 68, 79, 70, 75 };
|
|
|
|
|
|
|
|
gint i;
|
2000-04-01 23:48:48 +08:00
|
|
|
|
2004-04-22 07:09:16 +08:00
|
|
|
for (i = 0; i < G_N_ELEMENTS (good); i++)
|
2004-11-05 19:35:38 +08:00
|
|
|
{
|
2004-04-22 07:09:16 +08:00
|
|
|
gint value = TABLE_DRAWABLE - good[i];
|
|
|
|
|
|
|
|
gimp_int_combo_box_prepend (GIMP_INT_COMBO_BOX (combo),
|
|
|
|
GIMP_INT_STORE_VALUE, value,
|
|
|
|
GIMP_INT_STORE_LABEL, names[i],
|
|
|
|
-1);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2004-04-22 07:09:16 +08:00
|
|
|
gimp_int_combo_box_prepend (GIMP_INT_COMBO_BOX (combo),
|
2017-03-05 23:01:59 +08:00
|
|
|
GIMP_INT_STORE_VALUE, GRADIENT_DRAWABLE,
|
|
|
|
GIMP_INT_STORE_LABEL, _("Custom gradient"),
|
|
|
|
GIMP_INT_STORE_ICON_NAME, GIMP_ICON_GRADIENT,
|
2004-04-22 07:09:16 +08:00
|
|
|
-1);
|
|
|
|
|
|
|
|
gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo),
|
2019-08-31 20:42:33 +08:00
|
|
|
config.cmap_drawable_id,
|
2004-04-22 07:09:16 +08:00
|
|
|
G_CALLBACK (cmap_callback),
|
2019-08-08 06:22:15 +08:00
|
|
|
NULL, NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-05-20 23:51:25 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE, 0);
|
2004-04-22 07:09:16 +08:00
|
|
|
gtk_widget_show (combo);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-08-01 22:36:50 +08:00
|
|
|
cmap_preview = gimp_preview_area_new ();
|
|
|
|
gtk_widget_set_size_request (cmap_preview, 32, 32);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
gtk_box_pack_end (GTK_BOX (hbox), cmap_preview, FALSE, FALSE, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_widget_show (cmap_preview);
|
2004-04-22 07:09:16 +08:00
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
set_cmap_preview ();
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2018-05-08 21:45:17 +08:00
|
|
|
grid = gtk_grid_new ();
|
|
|
|
gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
|
|
|
|
gtk_grid_set_column_spacing (GTK_GRID (grid), 6);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (grid), 12);
|
2004-05-20 23:51:25 +08:00
|
|
|
|
2002-06-03 03:55:30 +08:00
|
|
|
label = gtk_label_new_with_mnemonic(_("C_amera"));
|
2018-05-08 21:45:17 +08:00
|
|
|
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), grid, label);
|
|
|
|
gtk_widget_show (grid);
|
2000-04-01 23:48:48 +08:00
|
|
|
|
2020-11-01 09:35:03 +08:00
|
|
|
scale = gimp_scale_entry_new (_("_Zoom:"), config.cp.zoom, -4, 4, 2);
|
2020-11-06 00:37:15 +08:00
|
|
|
gimp_label_spin_set_increments (GIMP_LABEL_SPIN (scale), 0.5, 1.0);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2020-10-31 07:53:26 +08:00
|
|
|
g_signal_connect (scale, "value-changed",
|
|
|
|
G_CALLBACK (flame_scale_entry_update_double),
|
2001-12-29 21:26:29 +08:00
|
|
|
&config.cp.zoom);
|
2020-10-31 07:53:26 +08:00
|
|
|
g_signal_connect (scale, "value-changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (set_flame_preview),
|
|
|
|
NULL);
|
2020-10-31 07:53:26 +08:00
|
|
|
gtk_grid_attach (GTK_GRID (grid), scale, 0, 0, 3, 1);
|
|
|
|
gtk_widget_show (scale);
|
2000-04-01 23:48:48 +08:00
|
|
|
|
2020-11-01 09:35:03 +08:00
|
|
|
scale = gimp_scale_entry_new (_("_X:"), config.cp.center[0], -2, 2, 2);
|
2020-11-06 00:37:15 +08:00
|
|
|
gimp_label_spin_set_increments (GIMP_LABEL_SPIN (scale), 0.5, 1.0);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2020-10-31 07:53:26 +08:00
|
|
|
g_signal_connect (scale, "value-changed",
|
|
|
|
G_CALLBACK (flame_scale_entry_update_double),
|
2001-12-29 21:26:29 +08:00
|
|
|
&config.cp.center[0]);
|
2020-10-31 07:53:26 +08:00
|
|
|
g_signal_connect (scale, "value-changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (set_flame_preview),
|
|
|
|
NULL);
|
2020-10-31 07:53:26 +08:00
|
|
|
gtk_grid_attach (GTK_GRID (grid), scale, 0, 1, 3, 1);
|
|
|
|
gtk_widget_show (scale);
|
2000-04-01 23:48:48 +08:00
|
|
|
|
2020-11-01 09:35:03 +08:00
|
|
|
scale = gimp_scale_entry_new (_("_Y:"), config.cp.center[1], -2, 2, 2);
|
2020-11-06 00:37:15 +08:00
|
|
|
gimp_label_spin_set_increments (GIMP_LABEL_SPIN (scale), 0.5, 1.0);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2020-10-31 07:53:26 +08:00
|
|
|
g_signal_connect (scale, "value-changed",
|
|
|
|
G_CALLBACK (flame_scale_entry_update_double),
|
2001-12-29 21:26:29 +08:00
|
|
|
&config.cp.center[1]);
|
2020-10-31 07:53:26 +08:00
|
|
|
g_signal_connect (scale, "value-changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (set_flame_preview),
|
|
|
|
NULL);
|
2020-10-31 07:53:26 +08:00
|
|
|
gtk_grid_attach (GTK_GRID (grid), scale, 0, 2, 3, 1);
|
|
|
|
gtk_widget_show (scale);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
set_flame_preview ();
|
1999-12-27 22:14:53 +08:00
|
|
|
|
2005-09-10 02:07:31 +08:00
|
|
|
gtk_widget_show (dialog);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-09-10 02:07:31 +08:00
|
|
|
run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK);
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2005-09-10 02:07:31 +08:00
|
|
|
gtk_widget_destroy (dialog);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
return run;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2020-10-31 07:53:26 +08:00
|
|
|
|
|
|
|
static void
|
2020-11-06 00:37:15 +08:00
|
|
|
flame_scale_entry_update_int (GimpLabelSpin *entry,
|
|
|
|
gint *value)
|
2020-10-31 07:53:26 +08:00
|
|
|
{
|
2020-11-06 00:37:15 +08:00
|
|
|
*value = (gint) gimp_label_spin_get_value (entry);
|
2020-10-31 07:53:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-11-06 00:37:15 +08:00
|
|
|
flame_scale_entry_update_double (GimpLabelSpin *entry,
|
|
|
|
gdouble *value)
|
2020-10-31 07:53:26 +08:00
|
|
|
{
|
2020-11-06 00:37:15 +08:00
|
|
|
*value = gimp_label_spin_get_value (entry);
|
2020-10-31 07:53:26 +08:00
|
|
|
}
|