mirror of https://github.com/GNOME/gimp.git
Reworked random seed handling once more:
2004-02-01 Michael Natterer <mitch@gimp.org> Reworked random seed handling once more: * libgimpwidgets/gimpwidgets.c (gimp_random_seed_new): make sure the displayed random seed value is always the one which will be used, whether "Randomize" is checked or not. * plug-ins/common/blur.c * plug-ins/common/plasma.c * plug-ins/common/randomize.c * plug-ins/common/sinus.c * plug-ins/common/snoise.c * plug-ins/maze/algorithms.c * plug-ins/maze/maze.c: if running interactively, always take the seed value produced by the gimp_random_seed widget and don't touch it because the widgets honors the "randomize" toggle correctly now. For noninteractive and last_vals runs, look at the "randomize" boolean and generate a seed if it is TRUE. Initialize the random number generators from the seed determined by either of the above ways and don't fiddle with it in the inner algorithms itself. * plug-ins/gflare/gflare.c (plugin_run): initialize the GRand from the seed unconditionally. (ed_make_page_sflare): no need to get the entry from the random seed widget to get its adjustment. Instead get the adjustment directly. (The random handling code of gflare looks somewhat broken, but that applies to the whole plug-in).
This commit is contained in:
parent
d7d5a4513a
commit
61ac7167d6
36
ChangeLog
36
ChangeLog
|
@ -1,3 +1,39 @@
|
||||||
|
2004-02-01 Michael Natterer <mitch@gimp.org>
|
||||||
|
|
||||||
|
Reworked random seed handling once more:
|
||||||
|
|
||||||
|
* libgimpwidgets/gimpwidgets.c (gimp_random_seed_new): make sure
|
||||||
|
the displayed random seed value is always the one which will be
|
||||||
|
used, whether "Randomize" is checked or not.
|
||||||
|
|
||||||
|
* plug-ins/common/blur.c
|
||||||
|
* plug-ins/common/plasma.c
|
||||||
|
* plug-ins/common/randomize.c
|
||||||
|
* plug-ins/common/sinus.c
|
||||||
|
* plug-ins/common/snoise.c
|
||||||
|
* plug-ins/maze/algorithms.c
|
||||||
|
* plug-ins/maze/maze.c: if running interactively, always take
|
||||||
|
the seed value produced by the gimp_random_seed widget and don't
|
||||||
|
touch it because the widgets honors the "randomize" toggle
|
||||||
|
correctly now.
|
||||||
|
|
||||||
|
For noninteractive and last_vals runs, look at the "randomize"
|
||||||
|
boolean and generate a seed if it is TRUE.
|
||||||
|
|
||||||
|
Initialize the random number generators from the seed determined
|
||||||
|
by either of the above ways and don't fiddle with it in the inner
|
||||||
|
algorithms itself.
|
||||||
|
|
||||||
|
* plug-ins/gflare/gflare.c (plugin_run): initialize the GRand
|
||||||
|
from the seed unconditionally.
|
||||||
|
|
||||||
|
(ed_make_page_sflare): no need to get the entry from the random
|
||||||
|
seed widget to get its adjustment. Instead get the adjustment
|
||||||
|
directly.
|
||||||
|
|
||||||
|
(The random handling code of gflare looks somewhat broken, but
|
||||||
|
that applies to the whole plug-in).
|
||||||
|
|
||||||
2004-02-01 Michael Natterer <mitch@gimp.org>
|
2004-02-01 Michael Natterer <mitch@gimp.org>
|
||||||
|
|
||||||
* app/plug-in/plug-ins.c (plug_ins_init): when removing a
|
* app/plug-in/plug-ins.c (plug_ins_init): when removing a
|
||||||
|
|
|
@ -1214,16 +1214,23 @@ static void
|
||||||
gimp_random_seed_update (GtkWidget *widget,
|
gimp_random_seed_update (GtkWidget *widget,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GtkWidget *w = data;
|
GtkWidget *spinbutton = data;
|
||||||
|
|
||||||
gtk_spin_button_set_value (GTK_SPIN_BUTTON (w),
|
/* Generate a new seed if the "New Seed" button was clicked or
|
||||||
(guint) g_random_int ());
|
* of the "Randomize" toggle is activated
|
||||||
|
*/
|
||||||
|
if (! GTK_IS_TOGGLE_BUTTON (widget) ||
|
||||||
|
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
|
||||||
|
{
|
||||||
|
gtk_spin_button_set_value (GTK_SPIN_BUTTON (spinbutton),
|
||||||
|
(guint) g_random_int ());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gimp_random_seed_new:
|
* gimp_random_seed_new:
|
||||||
* @seed: A pointer to the variable which stores the random seed.
|
* @seed: A pointer to the variable which stores the random seed.
|
||||||
* @random_seed: A pointer to a boolean indicating whether seed should be
|
* @random_seed: A pointer to a boolean indicating whether seed should be
|
||||||
* initialised randomly or not.
|
* initialised randomly or not.
|
||||||
*
|
*
|
||||||
* Creates a widget that allows the user to control how the random number
|
* Creates a widget that allows the user to control how the random number
|
||||||
|
@ -1233,7 +1240,8 @@ gimp_random_seed_update (GtkWidget *widget,
|
||||||
* a #GtkButton for setting a random seed.
|
* a #GtkButton for setting a random seed.
|
||||||
**/
|
**/
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
gimp_random_seed_new (guint *seed, gboolean *random_seed)
|
gimp_random_seed_new (guint *seed,
|
||||||
|
gboolean *random_seed)
|
||||||
{
|
{
|
||||||
GtkWidget *hbox;
|
GtkWidget *hbox;
|
||||||
GtkWidget *toggle;
|
GtkWidget *toggle;
|
||||||
|
@ -1241,61 +1249,69 @@ gimp_random_seed_new (guint *seed, gboolean *random_seed)
|
||||||
GtkObject *adj;
|
GtkObject *adj;
|
||||||
GtkWidget *button;
|
GtkWidget *button;
|
||||||
|
|
||||||
|
g_return_val_if_fail (seed != NULL, NULL);
|
||||||
|
g_return_val_if_fail (random_seed != NULL, NULL);
|
||||||
|
|
||||||
hbox = gtk_hbox_new (FALSE, 4);
|
hbox = gtk_hbox_new (FALSE, 4);
|
||||||
|
|
||||||
/* If we're being asked to generate a random seed, generate one. */
|
/* If we're being asked to generate a random seed, generate one. */
|
||||||
/* I'm not sure this should be here
|
|
||||||
if (*random_seed)
|
if (*random_seed)
|
||||||
{
|
*seed = g_random_int ();
|
||||||
*seed = g_random_int ();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
spinbutton = gimp_spin_button_new (&adj, *seed,
|
spinbutton = gimp_spin_button_new (&adj, *seed,
|
||||||
0, (guint32) -1 , 1, 10, 0, 1, 0);
|
0, (guint32) -1 , 1, 10, 0, 1, 0);
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0);
|
||||||
|
gtk_widget_show (spinbutton);
|
||||||
|
|
||||||
g_signal_connect (adj, "value_changed",
|
g_signal_connect (adj, "value_changed",
|
||||||
G_CALLBACK (gimp_uint_adjustment_update),
|
G_CALLBACK (gimp_uint_adjustment_update),
|
||||||
seed);
|
seed);
|
||||||
gtk_widget_show (spinbutton);
|
|
||||||
|
|
||||||
gimp_help_set_help_data (spinbutton,
|
gimp_help_set_help_data (spinbutton,
|
||||||
_("Use this value for random number generator "
|
_("Use this value for random number generator "
|
||||||
"seed - this allows you to repeat a "
|
"seed - this allows you to repeat a "
|
||||||
"given \"random\" operation"), NULL);
|
"given \"random\" operation"), NULL);
|
||||||
|
|
||||||
button = gtk_button_new_with_mnemonic (_("_New seed"));
|
button = gtk_button_new_with_mnemonic (_("_New Seed"));
|
||||||
gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0);
|
gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0);
|
||||||
/* Send spinbutton as data so that we can change the value in
|
|
||||||
* gimp_random_seed_update() */
|
|
||||||
g_signal_connect (button, "clicked",
|
|
||||||
G_CALLBACK (gimp_random_seed_update),
|
|
||||||
spinbutton);
|
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
||||||
gtk_widget_show (button);
|
gtk_widget_show (button);
|
||||||
|
|
||||||
|
/* Send spinbutton as data so that we can change the value in
|
||||||
|
* gimp_random_seed_update()
|
||||||
|
*/
|
||||||
|
g_signal_connect (button, "clicked",
|
||||||
|
G_CALLBACK (gimp_random_seed_update),
|
||||||
|
spinbutton);
|
||||||
|
|
||||||
gimp_help_set_help_data (button,
|
gimp_help_set_help_data (button,
|
||||||
_("Seed random number generator with a generated random number"),
|
_("Seed random number generator with a generated "
|
||||||
|
"random number"),
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
toggle = gtk_check_button_new_with_label (_("Randomize"));
|
toggle = gtk_check_button_new_with_label (_("Randomize"));
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), *random_seed);
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), *random_seed);
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), toggle, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (hbox), toggle, FALSE, FALSE, 0);
|
||||||
gtk_widget_show (toggle);
|
gtk_widget_show (toggle);
|
||||||
|
|
||||||
g_signal_connect (toggle, "toggled",
|
g_signal_connect (toggle, "toggled",
|
||||||
G_CALLBACK (gimp_toggle_button_update),
|
G_CALLBACK (gimp_toggle_button_update),
|
||||||
random_seed);
|
random_seed);
|
||||||
|
|
||||||
|
/* Need to create a new seed when the "Randomize" toggle is activated */
|
||||||
|
g_signal_connect (toggle, "toggled",
|
||||||
|
G_CALLBACK (gimp_random_seed_update),
|
||||||
|
spinbutton);
|
||||||
|
|
||||||
g_object_set_data (G_OBJECT (hbox), "spinbutton", spinbutton);
|
g_object_set_data (G_OBJECT (hbox), "spinbutton", spinbutton);
|
||||||
g_object_set_data (G_OBJECT (hbox), "button", button);
|
g_object_set_data (G_OBJECT (hbox), "button", button);
|
||||||
g_object_set_data (G_OBJECT (hbox), "toggle", toggle);
|
g_object_set_data (G_OBJECT (hbox), "toggle", toggle);
|
||||||
|
|
||||||
/* Set sensitivity data for the toggle, this stuff makes
|
/* Set sensitivity data for the toggle, this stuff makes
|
||||||
* gimp_toggle_button_sensitive_update work */
|
* gimp_toggle_button_sensitive_update work
|
||||||
|
*/
|
||||||
g_object_set_data (G_OBJECT (toggle), "inverse_sensitive", spinbutton);
|
g_object_set_data (G_OBJECT (toggle), "inverse_sensitive", spinbutton);
|
||||||
g_object_set_data (G_OBJECT (spinbutton), "inverse_sensitive", button);
|
g_object_set_data (G_OBJECT (spinbutton), "inverse_sensitive", button);
|
||||||
// g_object_set_data (G_OBJECT (button), "inverse_sensitive", adj);
|
|
||||||
|
|
||||||
/* Initialise sensitivity */
|
/* Initialise sensitivity */
|
||||||
gimp_toggle_button_update (toggle, random_seed);
|
gimp_toggle_button_update (toggle, random_seed);
|
||||||
|
|
|
@ -251,7 +251,7 @@ run (const gchar *name,
|
||||||
*/
|
*/
|
||||||
case GIMP_RUN_INTERACTIVE:
|
case GIMP_RUN_INTERACTIVE:
|
||||||
gimp_get_data (PLUG_IN_NAME, &pivals);
|
gimp_get_data (PLUG_IN_NAME, &pivals);
|
||||||
if (!blur_dialog ()) /* return on Cancel */
|
if (! blur_dialog ()) /* return on Cancel */
|
||||||
return;
|
return;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -273,6 +273,9 @@ run (const gchar *name,
|
||||||
pivals.blur_rcount = (gdouble) MAX (1.0, pivals.blur_rcount);
|
pivals.blur_rcount = (gdouble) MAX (1.0, pivals.blur_rcount);
|
||||||
pivals.blur_randomize = (gboolean) param[5].data.d_int32;
|
pivals.blur_randomize = (gboolean) param[5].data.d_int32;
|
||||||
pivals.blur_seed = (gint) param[6].data.d_int32;
|
pivals.blur_seed = (gint) param[6].data.d_int32;
|
||||||
|
|
||||||
|
if (pivals.blur_randomize)
|
||||||
|
pivals.blur_seed = g_random_int ();
|
||||||
}
|
}
|
||||||
else if ((strcmp (name, PLUG_IN_NAME) == 0) &&
|
else if ((strcmp (name, PLUG_IN_NAME) == 0) &&
|
||||||
(nparams == 3))
|
(nparams == 3))
|
||||||
|
@ -293,6 +296,9 @@ run (const gchar *name,
|
||||||
*/
|
*/
|
||||||
case GIMP_RUN_WITH_LAST_VALS:
|
case GIMP_RUN_WITH_LAST_VALS:
|
||||||
gimp_get_data (PLUG_IN_NAME, &pivals);
|
gimp_get_data (PLUG_IN_NAME, &pivals);
|
||||||
|
|
||||||
|
if (pivals.blur_randomize)
|
||||||
|
pivals.blur_seed = g_random_int ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -310,11 +316,8 @@ run (const gchar *name,
|
||||||
gimp_progress_init (_("Blurring..."));
|
gimp_progress_init (_("Blurring..."));
|
||||||
gimp_tile_cache_ntiles (2 * (drawable->width / gimp_tile_width ()
|
gimp_tile_cache_ntiles (2 * (drawable->width / gimp_tile_width ()
|
||||||
+ 1));
|
+ 1));
|
||||||
/*
|
|
||||||
* Initialize the rand() function seed
|
g_random_set_seed (pivals.blur_seed);
|
||||||
*/
|
|
||||||
if (pivals.blur_randomize)
|
|
||||||
g_random_set_seed (pivals.blur_seed);
|
|
||||||
|
|
||||||
blur (drawable);
|
blur (drawable);
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -237,7 +237,7 @@ run (const gchar *name,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pvals.seed = (guint32) param[3].data.d_int32;
|
pvals.seed = (guint32) param[3].data.d_int32;
|
||||||
pvals.turbulence = (gdouble) param[4].data.d_float;
|
pvals.turbulence = (gdouble) param[4].data.d_float;
|
||||||
|
|
||||||
if (pvals.turbulence <= 0)
|
if (pvals.turbulence <= 0)
|
||||||
|
@ -248,6 +248,7 @@ run (const gchar *name,
|
||||||
case GIMP_RUN_WITH_LAST_VALS:
|
case GIMP_RUN_WITH_LAST_VALS:
|
||||||
/* Possibly retrieve data */
|
/* Possibly retrieve data */
|
||||||
gimp_get_data ("plug_in_plasma", &pvals);
|
gimp_get_data ("plug_in_plasma", &pvals);
|
||||||
|
|
||||||
if (pvals.random_seed)
|
if (pvals.random_seed)
|
||||||
pvals.seed = g_random_int ();
|
pvals.seed = g_random_int ();
|
||||||
break;
|
break;
|
||||||
|
@ -347,11 +348,6 @@ plasma_dialog (GimpDrawable *drawable,
|
||||||
G_CALLBACK (plasma_seed_changed_callback),
|
G_CALLBACK (plasma_seed_changed_callback),
|
||||||
drawable);
|
drawable);
|
||||||
|
|
||||||
g_signal_connect_swapped (GIMP_RANDOM_SEED_TOGGLE (seed),
|
|
||||||
"toggled",
|
|
||||||
G_CALLBACK (plasma_seed_changed_callback),
|
|
||||||
drawable);
|
|
||||||
|
|
||||||
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 1,
|
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 1,
|
||||||
_("T_urbulence:"), SCALE_WIDTH, 0,
|
_("T_urbulence:"), SCALE_WIDTH, 0,
|
||||||
pvals.turbulence,
|
pvals.turbulence,
|
||||||
|
@ -378,9 +374,6 @@ static void
|
||||||
plasma_seed_changed_callback (GimpDrawable *drawable,
|
plasma_seed_changed_callback (GimpDrawable *drawable,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
if (pvals.random_seed)
|
|
||||||
pvals.seed = g_random_int ();
|
|
||||||
|
|
||||||
plasma (drawable, TRUE);
|
plasma (drawable, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -314,9 +314,9 @@ run (const gchar *name,
|
||||||
/*
|
/*
|
||||||
* Make sure the drawable type is appropriate.
|
* Make sure the drawable type is appropriate.
|
||||||
*/
|
*/
|
||||||
if (gimp_drawable_is_rgb(drawable->drawable_id) ||
|
if (gimp_drawable_is_rgb (drawable->drawable_id) ||
|
||||||
gimp_drawable_is_gray(drawable->drawable_id) ||
|
gimp_drawable_is_gray (drawable->drawable_id) ||
|
||||||
gimp_drawable_is_indexed(drawable->drawable_id))
|
gimp_drawable_is_indexed (drawable->drawable_id))
|
||||||
{
|
{
|
||||||
switch (run_mode)
|
switch (run_mode)
|
||||||
{
|
{
|
||||||
|
@ -324,8 +324,9 @@ run (const gchar *name,
|
||||||
* If we're running interactively, pop up the dialog box.
|
* If we're running interactively, pop up the dialog box.
|
||||||
*/
|
*/
|
||||||
case GIMP_RUN_INTERACTIVE:
|
case GIMP_RUN_INTERACTIVE:
|
||||||
gimp_get_data(PLUG_IN_NAME[rndm_type - 1], &pivals);
|
gimp_get_data (PLUG_IN_NAME[rndm_type - 1], &pivals);
|
||||||
if (!randomize_dialog()) /* return on Cancel */
|
|
||||||
|
if (! randomize_dialog ()) /* return on Cancel */
|
||||||
return;
|
return;
|
||||||
break;
|
break;
|
||||||
/*
|
/*
|
||||||
|
@ -341,10 +342,13 @@ run (const gchar *name,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pivals.rndm_pct = (gdouble) param[3].data.d_float;
|
pivals.rndm_pct = (gdouble) param[3].data.d_float;
|
||||||
pivals.rndm_rcount = (gdouble) param[4].data.d_float;
|
pivals.rndm_rcount = (gdouble) param[4].data.d_float;
|
||||||
pivals.randomize = (gboolean) param[5].data.d_int32;
|
pivals.randomize = (gboolean) param[5].data.d_int32;
|
||||||
pivals.seed = (gint) param[6].data.d_int32;
|
pivals.seed = (gint) param[6].data.d_int32;
|
||||||
|
|
||||||
|
if (pivals.randomize)
|
||||||
|
pivals.seed = g_random_int ();
|
||||||
|
|
||||||
if ((rndm_type != RNDM_PICK &&
|
if ((rndm_type != RNDM_PICK &&
|
||||||
rndm_type != RNDM_SLUR &&
|
rndm_type != RNDM_SLUR &&
|
||||||
|
@ -361,6 +365,9 @@ run (const gchar *name,
|
||||||
*/
|
*/
|
||||||
case GIMP_RUN_WITH_LAST_VALS:
|
case GIMP_RUN_WITH_LAST_VALS:
|
||||||
gimp_get_data (PLUG_IN_NAME[rndm_type - 1], &pivals);
|
gimp_get_data (PLUG_IN_NAME[rndm_type - 1], &pivals);
|
||||||
|
|
||||||
|
if (pivals.randomize)
|
||||||
|
pivals.seed = g_random_int ();
|
||||||
break;
|
break;
|
||||||
/*
|
/*
|
||||||
* Hopefully we never get here!
|
* Hopefully we never get here!
|
||||||
|
@ -368,6 +375,7 @@ run (const gchar *name,
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status == GIMP_PDB_SUCCESS)
|
if (status == GIMP_PDB_SUCCESS)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
@ -379,16 +387,16 @@ run (const gchar *name,
|
||||||
case RNDM_PICK: rndm_type_str = "pick"; break;
|
case RNDM_PICK: rndm_type_str = "pick"; break;
|
||||||
case RNDM_SLUR: rndm_type_str = "slur"; break;
|
case RNDM_SLUR: rndm_type_str = "slur"; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf (prog_label, "%s (%s)...",
|
sprintf (prog_label, "%s (%s)...",
|
||||||
gettext(RNDM_VERSION[rndm_type - 1]),
|
gettext (RNDM_VERSION[rndm_type - 1]),
|
||||||
gettext(rndm_type_str));
|
gettext (rndm_type_str));
|
||||||
gimp_progress_init(prog_label);
|
gimp_progress_init (prog_label);
|
||||||
gimp_tile_cache_ntiles(2 * (drawable->width / gimp_tile_width() + 1));
|
gimp_tile_cache_ntiles (2 * (drawable->width / gimp_tile_width () + 1));
|
||||||
/*
|
/*
|
||||||
* Initialize the g_rand() function seed
|
* Initialize the g_rand() function seed
|
||||||
*/
|
*/
|
||||||
if (!pivals.randomize)
|
g_rand_set_seed (gr, pivals.seed);
|
||||||
g_rand_set_seed (gr, pivals.seed);
|
|
||||||
|
|
||||||
randomize (drawable, gr);
|
randomize (drawable, gr);
|
||||||
/*
|
/*
|
||||||
|
@ -396,15 +404,15 @@ run (const gchar *name,
|
||||||
*/
|
*/
|
||||||
if (run_mode != GIMP_RUN_NONINTERACTIVE)
|
if (run_mode != GIMP_RUN_NONINTERACTIVE)
|
||||||
{
|
{
|
||||||
gimp_displays_flush();
|
gimp_displays_flush ();
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* If we use the dialog popup, set the data for future use.
|
* If we use the dialog popup, set the data for future use.
|
||||||
*/
|
*/
|
||||||
if (run_mode == GIMP_RUN_INTERACTIVE)
|
if (run_mode == GIMP_RUN_INTERACTIVE)
|
||||||
{
|
{
|
||||||
gimp_set_data(PLUG_IN_NAME[rndm_type - 1], &pivals,
|
gimp_set_data (PLUG_IN_NAME[rndm_type - 1], &pivals,
|
||||||
sizeof(RandomizeVals));
|
sizeof (RandomizeVals));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ typedef struct
|
||||||
glong colors;
|
glong colors;
|
||||||
GimpRGB col1;
|
GimpRGB col1;
|
||||||
GimpRGB col2;
|
GimpRGB col2;
|
||||||
gboolean random_seed;
|
gboolean random_seed;
|
||||||
} SinusVals;
|
} SinusVals;
|
||||||
|
|
||||||
static SinusVals svals =
|
static SinusVals svals =
|
||||||
|
@ -87,7 +87,8 @@ static SinusVals svals =
|
||||||
LINEAR,
|
LINEAR,
|
||||||
USE_COLORS,
|
USE_COLORS,
|
||||||
{ 1.0, 1.0, 0.0, 1.0 },
|
{ 1.0, 1.0, 0.0, 1.0 },
|
||||||
{ 0.0, 0.0, 1.0, 1.0 }
|
{ 0.0, 0.0, 1.0, 1.0 },
|
||||||
|
FALSE
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -231,7 +232,7 @@ run (const gchar *name,
|
||||||
thePreview = mw_preview_build_virgin(drawable);
|
thePreview = mw_preview_build_virgin(drawable);
|
||||||
drawable_is_grayscale = gimp_drawable_is_gray (drawable->drawable_id);
|
drawable_is_grayscale = gimp_drawable_is_gray (drawable->drawable_id);
|
||||||
|
|
||||||
if (!sinus_dialog())
|
if (! sinus_dialog ())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -257,12 +258,18 @@ run (const gchar *name,
|
||||||
gimp_rgb_set_alpha (&svals.col2, param[13].data.d_float);
|
gimp_rgb_set_alpha (&svals.col2, param[13].data.d_float);
|
||||||
svals.colorization = param[14].data.d_int32;
|
svals.colorization = param[14].data.d_int32;
|
||||||
svals.blend_power = param[15].data.d_float;
|
svals.blend_power = param[15].data.d_float;
|
||||||
|
|
||||||
|
if (svals.random_seed)
|
||||||
|
svals.seed = g_random_int ();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GIMP_RUN_WITH_LAST_VALS:
|
case GIMP_RUN_WITH_LAST_VALS:
|
||||||
/* Possibly retrieve data */
|
/* Possibly retrieve data */
|
||||||
gimp_get_data ("plug_in_sinus", &svals);
|
gimp_get_data ("plug_in_sinus", &svals);
|
||||||
|
|
||||||
|
if (svals.random_seed)
|
||||||
|
svals.seed = g_random_int ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -313,8 +320,7 @@ prepare_coef (params *p)
|
||||||
|
|
||||||
gr = g_rand_new ();
|
gr = g_rand_new ();
|
||||||
|
|
||||||
if (!svals.random_seed)
|
g_rand_set_seed (gr, svals.seed);
|
||||||
g_rand_set_seed (gr, svals.seed);
|
|
||||||
|
|
||||||
switch (svals.colorization)
|
switch (svals.colorization)
|
||||||
{
|
{
|
||||||
|
|
|
@ -231,12 +231,18 @@ run (const gchar *name,
|
||||||
snvals.detail = param[6].data.d_int32;
|
snvals.detail = param[6].data.d_int32;
|
||||||
snvals.xsize = param[7].data.d_float;
|
snvals.xsize = param[7].data.d_float;
|
||||||
snvals.ysize = param[8].data.d_float;
|
snvals.ysize = param[8].data.d_float;
|
||||||
|
|
||||||
|
if (snvals.random_seed)
|
||||||
|
snvals.seed = g_random_int ();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GIMP_RUN_WITH_LAST_VALS:
|
case GIMP_RUN_WITH_LAST_VALS:
|
||||||
/* Possibly retrieve data */
|
/* Possibly retrieve data */
|
||||||
gimp_get_data ("plug_in_solid_noise", &snvals);
|
gimp_get_data ("plug_in_solid_noise", &snvals);
|
||||||
|
|
||||||
|
if (snvals.random_seed)
|
||||||
|
snvals.seed = g_random_int ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -358,8 +364,8 @@ solid_noise_init (void)
|
||||||
GRand *gr;
|
GRand *gr;
|
||||||
|
|
||||||
gr = g_rand_new ();
|
gr = g_rand_new ();
|
||||||
if (!snvals.random_seed)
|
|
||||||
g_rand_set_seed (gr, snvals.seed);
|
g_rand_set_seed (gr, snvals.seed);
|
||||||
|
|
||||||
/* Force sane parameters */
|
/* Force sane parameters */
|
||||||
snvals.detail = CLAMP (snvals.detail, 0, 15);
|
snvals.detail = CLAMP (snvals.detail, 0, 15);
|
||||||
|
|
|
@ -926,11 +926,6 @@ plugin_run (const gchar *name,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GIMP_RUN_NONINTERACTIVE:
|
case GIMP_RUN_NONINTERACTIVE:
|
||||||
#if 0
|
|
||||||
printf("Currently non interactive call of gradient flare is not supported\n");
|
|
||||||
status = GIMP_PDB_CALLING_ERROR;
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
if (nparams != 14)
|
if (nparams != 14)
|
||||||
{
|
{
|
||||||
status = GIMP_PDB_CALLING_ERROR;
|
status = GIMP_PDB_CALLING_ERROR;
|
||||||
|
@ -1883,8 +1878,7 @@ calc_place_sflare (void)
|
||||||
prob[i] = sum2 / sum;
|
prob[i] = sum2 / sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gflare->random_seed)
|
g_rand_set_seed (gr, gflare->sflare_seed);
|
||||||
g_rand_set_seed (gr, gflare->sflare_seed);
|
|
||||||
|
|
||||||
for (n = 0; n < SFLARE_NUM; n++)
|
for (n = 0; n < SFLARE_NUM; n++)
|
||||||
{
|
{
|
||||||
|
@ -3696,7 +3690,6 @@ ed_make_page_sflare (GFlareEditor *ed,
|
||||||
GtkObject *adj;
|
GtkObject *adj;
|
||||||
gchar buf[256];
|
gchar buf[256];
|
||||||
gint row;
|
gint row;
|
||||||
gboolean randomize = FALSE;
|
|
||||||
|
|
||||||
vbox = gtk_vbox_new (FALSE, 4);
|
vbox = gtk_vbox_new (FALSE, 4);
|
||||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
|
||||||
|
@ -3853,14 +3846,10 @@ ed_make_page_sflare (GFlareEditor *ed,
|
||||||
gtk_widget_show (label);
|
gtk_widget_show (label);
|
||||||
|
|
||||||
seed = gimp_random_seed_new (&gflare->sflare_seed, &gflare->random_seed);
|
seed = gimp_random_seed_new (&gflare->sflare_seed, &gflare->random_seed);
|
||||||
|
|
||||||
entry = GTK_WIDGET (GIMP_RANDOM_SEED_SPINBUTTON (seed));
|
|
||||||
|
|
||||||
gtk_box_pack_start (GTK_BOX (seed_hbox), seed, FALSE, TRUE, 0);
|
gtk_box_pack_start (GTK_BOX (seed_hbox), seed, FALSE, TRUE, 0);
|
||||||
gtk_widget_show (seed);
|
gtk_widget_show (seed);
|
||||||
|
|
||||||
g_signal_connect (GTK_SPIN_BUTTON (entry)->adjustment,
|
g_signal_connect (GIMP_RANDOM_SEED_SPINBUTTON_ADJ (seed), "value_changed",
|
||||||
"value_changed",
|
|
||||||
G_CALLBACK (ed_preview_update),
|
G_CALLBACK (ed_preview_update),
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
|
|
@ -280,14 +280,9 @@ prim(gint pos, gchar *maz, guint x, guint y)
|
||||||
guint progress=0, max_progress;
|
guint progress=0, max_progress;
|
||||||
char d, i;
|
char d, i;
|
||||||
guint c=0;
|
guint c=0;
|
||||||
gint rnd;
|
gint rnd = mvals.seed;
|
||||||
|
|
||||||
if (mvals.random_seed)
|
g_rand_set_seed (gr, rnd);
|
||||||
rnd = g_random_int ();
|
|
||||||
else
|
|
||||||
rnd = mvals.seed;
|
|
||||||
|
|
||||||
g_rand_set_seed (gr, rnd);
|
|
||||||
|
|
||||||
gimp_progress_init (_("Constructing maze using Prim's Algorithm..."));
|
gimp_progress_init (_("Constructing maze using Prim's Algorithm..."));
|
||||||
|
|
||||||
|
@ -461,14 +456,9 @@ prim_tileable(gchar *maz, guint x, guint y)
|
||||||
guint progress=0, max_progress;
|
guint progress=0, max_progress;
|
||||||
char d, i;
|
char d, i;
|
||||||
guint c=0;
|
guint c=0;
|
||||||
gint rnd;
|
gint rnd = mvals.seed;
|
||||||
|
|
||||||
if (mvals.random_seed)
|
g_rand_set_seed (gr, rnd);
|
||||||
rnd = g_random_int ();
|
|
||||||
else
|
|
||||||
rnd = mvals.seed;
|
|
||||||
|
|
||||||
g_rand_set_seed (gr, rnd);
|
|
||||||
|
|
||||||
gimp_progress_init (_("Constructing tileable maze using Prim's Algorithm..."));
|
gimp_progress_init (_("Constructing tileable maze using Prim's Algorithm..."));
|
||||||
|
|
||||||
|
|
|
@ -212,7 +212,8 @@ run (const gchar *name,
|
||||||
|
|
||||||
/* The interface needs to know the dimensions of the image... */
|
/* The interface needs to know the dimensions of the image... */
|
||||||
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
|
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
|
||||||
sel_w=x2-x1; sel_h=y2-y1;
|
sel_w = x2 - x1;
|
||||||
|
sel_h = y2 - y1;
|
||||||
|
|
||||||
/* Acquire info with a dialog */
|
/* Acquire info with a dialog */
|
||||||
if (! maze_dialog ())
|
if (! maze_dialog ())
|
||||||
|
@ -235,12 +236,18 @@ run (const gchar *name,
|
||||||
mvals.seed = (guint32) param[7].data.d_int32;
|
mvals.seed = (guint32) param[7].data.d_int32;
|
||||||
mvals.multiple = (gint16) param[8].data.d_int16;
|
mvals.multiple = (gint16) param[8].data.d_int16;
|
||||||
mvals.offset = (gint16) param[9].data.d_int16;
|
mvals.offset = (gint16) param[9].data.d_int16;
|
||||||
|
|
||||||
|
if (mvals.random_seed)
|
||||||
|
mvals.seed = g_random_int ();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GIMP_RUN_WITH_LAST_VALS:
|
case GIMP_RUN_WITH_LAST_VALS:
|
||||||
/* Possibly retrieve data */
|
/* Possibly retrieve data */
|
||||||
gimp_get_data ("plug_in_maze", &mvals);
|
gimp_get_data ("plug_in_maze", &mvals);
|
||||||
|
|
||||||
|
if (mvals.random_seed)
|
||||||
|
mvals.seed = g_random_int ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -367,10 +374,7 @@ maze (GimpDrawable * drawable)
|
||||||
switch (mvals.algorithm)
|
switch (mvals.algorithm)
|
||||||
{
|
{
|
||||||
case DEPTH_FIRST:
|
case DEPTH_FIRST:
|
||||||
if (mvals.random_seed)
|
mazegen_tileable (0, maz, mw, mh, mvals.seed);
|
||||||
mazegen_tileable (0, maz, mw, mh, g_random_int ());
|
|
||||||
else
|
|
||||||
mazegen_tileable (0, maz, mw, mh, mvals.seed);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PRIMS_ALGORITHM:
|
case PRIMS_ALGORITHM:
|
||||||
|
@ -400,10 +404,7 @@ maze (GimpDrawable * drawable)
|
||||||
switch (mvals.algorithm)
|
switch (mvals.algorithm)
|
||||||
{
|
{
|
||||||
case DEPTH_FIRST:
|
case DEPTH_FIRST:
|
||||||
if (mvals.random_seed)
|
mazegen (maz_yy+maz_xx, maz, mw, mh, mvals.seed);
|
||||||
mazegen (maz_yy+maz_xx, maz, mw, mh, g_random_int());
|
|
||||||
else
|
|
||||||
mazegen (maz_yy+maz_xx, maz, mw, mh, mvals.seed);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PRIMS_ALGORITHM:
|
case PRIMS_ALGORITHM:
|
||||||
|
@ -425,10 +426,7 @@ maze (GimpDrawable * drawable)
|
||||||
switch (mvals.algorithm)
|
switch (mvals.algorithm)
|
||||||
{
|
{
|
||||||
case DEPTH_FIRST:
|
case DEPTH_FIRST:
|
||||||
if (mvals.random_seed)
|
mazegen (pos, maz, mw, mh, mvals.seed);
|
||||||
mazegen (pos, maz, mw, mh, g_random_int ());
|
|
||||||
else
|
|
||||||
mazegen (pos, maz, mw, mh, mvals.seed);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PRIMS_ALGORITHM:
|
case PRIMS_ALGORITHM:
|
||||||
|
|
Loading…
Reference in New Issue