gimp/plug-ins/common/nova.c

1017 lines
28 KiB
C
Raw Normal View History

1997-11-24 22:05:25 +00:00
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* SuperNova plug-in
* Copyright (C) 1997 Eiichi Takamori <taka@ma1.seikyou.ne.jp>,
1999-09-03 23:14:44 +00:00
* Spencer Kimball, Federico Mena Quintero
1997-11-24 22:05:25 +00:00
*
* 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 2 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
1999-09-03 23:14:44 +00:00
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1997-11-24 22:05:25 +00:00
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1997-11-24 22:05:25 +00:00
*/
/*
* version 1.200
1997-11-24 22:05:25 +00:00
*
* This plug-in produces an effect like a supernova burst.
*
1999-09-03 23:14:44 +00:00
* Eiichi Takamori <taka@ma1.seikyou.ne.jp>
* http://ha1.seikyou.ne.jp/home/taka/gimp/
1997-11-24 22:05:25 +00:00
*
* Preview render mode by timecop@japan.co.jp
* http://www.ne.jp/asahi/linux/timecop
1997-11-24 22:05:25 +00:00
*
* Changes from version 1.122 to version 1.200 by tim copperfield:
* - preview mode now previews the nova with scale;
* - toggle for cursor show/hide during preview
*
1999-09-03 23:14:44 +00:00
* Changes from version 1.1115 to version 1.122 by Martin Weber:
* - Little bug fixes
* - Added random hue
* - Freeing memory
*
1997-11-24 22:05:25 +00:00
* Changes from version 1.1114 to version 1.1115:
* - Added gtk_rc_parse
* - Fixed bug that drawing preview of small height image
* (maybe image height < PREVIEW_SIZE) caused core dump.
* - Changed default value.
* - Moved to <Image>/Filters/Effects. right?
* - etc...
*
* Changes from version 1.1112 to version 1.1114:
* - Modified proc args to GIMP_PDB_COLOR, also included nspoke.
1997-11-24 22:05:25 +00:00
* - nova_int_entryscale_new(): Fixed caption was guchar -> gchar, etc.
* - Now nova renders properly with alpha channel.
* (Very thanks to Spencer Kimball and Federico Mena !)
*
* TODO:
* - clean up the code more
* - add notebook interface and so on
*/
#include "config.h"
1997-11-24 22:05:25 +00:00
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
1997-11-24 22:05:25 +00:00
#include <time.h>
#include <gtk/gtk.h>
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
#include "libgimp/stdplugins-intl.h"
1997-11-24 22:05:25 +00:00
1997-11-24 22:05:25 +00:00
#ifdef RCSID
static char rcsid[] = "$Id$";
#endif
#define ENTRY_WIDTH 50
2000-01-09 15:51:46 +00:00
#define SCALE_WIDTH 125
#define TILE_CACHE_SIZE 16
1997-11-24 22:05:25 +00:00
1999-09-03 23:14:44 +00:00
#define PREVIEW 0x1
#define CURSOR 0x2
#define ALL 0xf
1997-11-24 22:05:25 +00:00
#define PREVIEW_MASK (GDK_EXPOSURE_MASK | \
GDK_BUTTON_PRESS_MASK | \
GDK_BUTTON1_MOTION_MASK)
1997-11-24 22:05:25 +00:00
static GimpFixMePreview *preview;
static gboolean show_cursor = FALSE;
typedef struct
{
gint xcenter;
gint ycenter;
GimpRGB color;
1999-09-03 23:14:44 +00:00
gint radius;
gint nspoke;
gint randomhue;
1997-11-24 22:05:25 +00:00
} NovaValues;
typedef struct
{
1997-11-24 22:05:25 +00:00
gint run;
} NovaInterface;
typedef struct
{
GimpDrawable *drawable;
gint dwidth;
gint dheight;
gint bpp;
GtkObject *xadj;
GtkObject *yadj;
gint cursor;
gint curx, cury; /* x,y of cursor in preview */
gint oldx, oldy;
gboolean in_call;
1997-11-24 22:05:25 +00:00
} NovaCenter;
/* Declare a local function.
*/
static void query (void);
static void run (gchar *name,
gint nparams,
GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);
static void nova (GimpDrawable *drawable,
gboolean preview_mode);
static gint nova_dialog (GimpDrawable *drawable);
static void nova_ok_callback (GtkWidget *widget,
gpointer data);
static GtkWidget * nova_center_create (GimpDrawable *drawable);
static void nova_center_destroy (GtkWidget *widget,
gpointer data);
static void nova_center_draw (NovaCenter *center,
gint update);
static void nova_center_adjustment_update (GtkAdjustment *widget,
gpointer data);
static void nova_center_cursor_update (NovaCenter *center);
static gint nova_center_preview_expose (GtkWidget *widget,
GdkEvent *event,
gpointer data);
static gint nova_center_preview_events (GtkWidget *widget,
GdkEvent *event,
gpointer data);
GimpPlugInInfo PLUG_IN_INFO =
1997-11-24 22:05:25 +00:00
{
NULL, /* init_proc */
NULL, /* quit_proc */
query, /* query_proc */
run, /* run_proc */
1997-11-24 22:05:25 +00:00
};
static NovaValues pvals =
{
128, 128, /* xcenter, ycenter */
{ 0.35, 0.39, 1.0, 1.0 }, /* color */
20, /* radius */
100, /* nspoke */
0 /* random hue */
1997-11-24 22:05:25 +00:00
};
static NovaInterface pint =
{
1999-09-03 23:14:44 +00:00
FALSE /* run */
1997-11-24 22:05:25 +00:00
};
MAIN ()
1997-11-24 22:05:25 +00:00
static void
query (void)
1997-11-24 22:05:25 +00:00
{
static GimpParamDef args[]=
{
{ GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive" },
{ GIMP_PDB_IMAGE, "image", "Input image (unused)" },
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable" },
{ GIMP_PDB_INT32, "xcenter", "X coordinates of the center of supernova" },
{ GIMP_PDB_INT32, "ycenter", "Y coordinates of the center of supernova" },
{ GIMP_PDB_COLOR, "color", "Color of supernova" },
{ GIMP_PDB_INT32, "radius", "Radius of supernova" },
{ GIMP_PDB_INT32, "nspoke", "Number of spokes" },
{ GIMP_PDB_INT32, "randomhue", "Random hue" }
};
2000-01-09 15:51:46 +00:00
1997-11-24 22:05:25 +00:00
gimp_install_procedure ("plug_in_nova",
2000-01-31 02:32:30 +00:00
"Produce Supernova effect to the specified drawable",
"This plug-in produces an effect like a supernova "
"burst. The amount of the light effect is "
"approximately in proportion to 1/r, where r is the "
"distance from the center of the star. It works with "
"RGB*, GRAY* image.",
1999-09-03 23:14:44 +00:00
"Eiichi Takamori",
"Eiichi Takamori",
"May 2000",
/* don't translate '<Image>', it's a keyword
* of the gtk toolkit */
N_("<Image>/Filters/Light Effects/SuperNova..."),
1999-09-03 23:14:44 +00:00
"RGB*, GRAY*",
GIMP_PLUGIN,
G_N_ELEMENTS (args), 0,
args, NULL);
1997-11-24 22:05:25 +00:00
}
static void
run (gchar *name,
gint nparams,
GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals)
1997-11-24 22:05:25 +00:00
{
static GimpParam values[1];
GimpDrawable *drawable;
GimpRunMode run_mode;
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
1997-11-24 22:05:25 +00:00
INIT_I18N ();
1999-11-17 14:39:11 +00:00
1997-11-24 22:05:25 +00:00
run_mode = param[0].data.d_int32;
*nreturn_vals = 1;
*return_vals = values;
1997-11-24 22:05:25 +00:00
values[0].type = GIMP_PDB_STATUS;
1997-11-24 22:05:25 +00:00
values[0].data.d_status = status;
/* Get the specified drawable */
drawable = gimp_drawable_get (param[2].data.d_drawable);
switch (run_mode)
{
case GIMP_RUN_INTERACTIVE:
1997-11-24 22:05:25 +00:00
/* Possibly retrieve data */
gimp_get_data ("plug_in_nova", &pvals);
/* First acquire information with a dialog */
if (! nova_dialog (drawable))
1999-09-03 23:14:44 +00:00
{
gimp_drawable_detach (drawable);
return;
}
1997-11-24 22:05:25 +00:00
break;
case GIMP_RUN_NONINTERACTIVE:
1997-11-24 22:05:25 +00:00
/* Make sure all the arguments are there! */
1999-09-03 23:14:44 +00:00
if (nparams != 9)
status = GIMP_PDB_CALLING_ERROR;
if (status == GIMP_PDB_SUCCESS)
1999-09-03 23:14:44 +00:00
{
pvals.xcenter = param[3].data.d_int32;
pvals.ycenter = param[4].data.d_int32;
tools/pdbgen/lib.pl tools/pdbgen/pdb.pl tools/pdbgen/pdb/channel.pdb 2001-01-25 Sven Neumann <sven@gimp.org> * tools/pdbgen/lib.pl * tools/pdbgen/pdb.pl * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/tools.pdb: changed these with the help of Yosh. PDB functions take GimpRGB as color type now. * app/plug_in.c * app/pdb/channel_cmds.c * app/pdb/internal_procs.c * app/pdb/palette_cmds.c * app/pdb/procedural_db.[ch] * app/pdb/tools_cmds.c * libgimp/gimp.[ch] * libgimp/gimpchannel.[ch] * libgimp/gimpchannel_pdb.[ch] * libgimp/gimppalette_pdb.[ch] * libgimp/gimpprotocol.[ch] * libgimp/gimptools_pdb.[ch]: incremented Gimp protocol version and changed color type from array of chars to GimpRGB. * libgimp/Makefile.am * libgimp/gimppalette.[ch]: removed these files again * app/libgimp_glue.[ch] * libgimpwidgets/gimpcolorbutton.c * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_preview.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_preview.c * plug-ins/common/apply_lens.c * plug-ins/common/blinds.c * plug-ins/common/borderaverage.c * plug-ins/common/checkerboard.c * plug-ins/common/colorify.c * plug-ins/common/colortoalpha.c * plug-ins/common/cubism.c * plug-ins/common/exchange.c * plug-ins/common/film.c * plug-ins/common/gif.c * plug-ins/common/grid.c * plug-ins/common/mapcolor.c * plug-ins/common/mblur.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/png.c * plug-ins/common/polar.c * plug-ins/common/psd.c * plug-ins/common/semiflatten.c * plug-ins/common/sinus.c * plug-ins/common/sparkle.c * plug-ins/common/tiff.c * plug-ins/common/vpropagate.c * plug-ins/common/warp.c * plug-ins/common/whirlpinch.c * plug-ins/gap/gap_filter_iterators.c * plug-ins/gap/gap_mov_dialog.c * plug-ins/gdyntext/gdyntext.c * plug-ins/gfig/gfig.c * plug-ins/gfli/gfli.c * plug-ins/ifscompose/ifscompose.c * plug-ins/maze/handy.c * plug-ins/mosaic/mosaic.c * plug-ins/pagecurl/pagecurl.c * plug-ins/script-fu/script-fu-scripts.c * plug-ins/script-fu/script-fu.c * plug-ins/xjt/xjt.c: changed accordingly. A few plug-ins need to be looked at more closely after this change. I tried to put FIXME comments into those.
2001-01-25 01:20:05 +00:00
pvals.color = param[5].data.d_color;
pvals.radius = param[6].data.d_int32;
pvals.nspoke = param[7].data.d_int32;
1999-09-03 23:14:44 +00:00
pvals.randomhue = param[8].data.d_int32;
}
if ((status == GIMP_PDB_SUCCESS) &&
pvals.radius <= 0)
status = GIMP_PDB_CALLING_ERROR;
1997-11-24 22:05:25 +00:00
break;
case GIMP_RUN_WITH_LAST_VALS:
1997-11-24 22:05:25 +00:00
/* Possibly retrieve data */
gimp_get_data ("plug_in_nova", &pvals);
break;
default:
break;
}
if (status == GIMP_PDB_SUCCESS)
1997-11-24 22:05:25 +00:00
{
/* Make sure that the drawable is gray or RGB color */
if (gimp_drawable_is_rgb (drawable->drawable_id) ||
gimp_drawable_is_gray (drawable->drawable_id))
1999-09-03 23:14:44 +00:00
{
gimp_progress_init (_("Rendering SuperNova..."));
1999-09-03 23:14:44 +00:00
gimp_tile_cache_ntiles (TILE_CACHE_SIZE);
1997-11-24 22:05:25 +00:00
nova (drawable, 0);
1997-11-24 22:05:25 +00:00
if (run_mode != GIMP_RUN_NONINTERACTIVE)
1999-09-03 23:14:44 +00:00
gimp_displays_flush ();
1997-11-24 22:05:25 +00:00
1999-09-03 23:14:44 +00:00
/* Store data */
if (run_mode == GIMP_RUN_INTERACTIVE)
1999-09-03 23:14:44 +00:00
gimp_set_data ("plug_in_nova", &pvals, sizeof (NovaValues));
}
1997-11-24 22:05:25 +00:00
else
1999-09-03 23:14:44 +00:00
{
/* gimp_message ("nova: cannot operate on indexed color images"); */
status = GIMP_PDB_EXECUTION_ERROR;
1999-09-03 23:14:44 +00:00
}
1997-11-24 22:05:25 +00:00
}
values[0].data.d_status = status;
gimp_drawable_detach (drawable);
}
/*******************/
/* Main Dialog */
/*******************/
static gint
nova_dialog (GimpDrawable *drawable)
1997-11-24 22:05:25 +00:00
{
GtkWidget *dlg;
GtkWidget *frame;
GtkWidget *table;
GtkWidget *button;
GtkWidget *center_frame;
GtkObject *adj;
1997-11-24 22:05:25 +00:00
gimp_ui_init ("nova", TRUE);
1997-11-24 22:05:25 +00:00
dlg = gimp_dialog_new (_("SuperNova"), "nova",
gimp_standard_help_func, "filters/nova.html",
GTK_WIN_POS_MOUSE,
FALSE, TRUE, FALSE,
1997-11-24 22:05:25 +00:00
2001-08-03 19:52:08 +00:00
GTK_STOCK_CANCEL, gtk_widget_destroy,
NULL, 1, NULL, FALSE, TRUE,
GTK_STOCK_OK, nova_ok_callback,
NULL, NULL, NULL, TRUE, FALSE,
1997-11-24 22:05:25 +00:00
NULL);
g_signal_connect (dlg, "destroy",
G_CALLBACK (gtk_main_quit),
NULL);
1997-11-24 22:05:25 +00:00
/* parameter settings */
frame = gtk_frame_new (_("Parameter Settings"));
1997-11-24 22:05:25 +00:00
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
gtk_container_set_border_width (GTK_CONTAINER (frame), 6);
1997-11-24 22:05:25 +00:00
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), frame, TRUE, TRUE, 0);
table = gtk_table_new (5, 3, FALSE);
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
gtk_container_set_border_width (GTK_CONTAINER (table), 4);
1997-11-24 22:05:25 +00:00
gtk_container_add (GTK_CONTAINER (frame), table);
center_frame = nova_center_create (drawable);
gtk_table_attach (GTK_TABLE (table), center_frame, 0, 3, 0, 1,
0, 0, 0, 0);
button = gimp_color_button_new (_("SuperNova Color Picker"),
SCALE_WIDTH - 8, 16,
&pvals.color, GIMP_COLOR_AREA_FLAT);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 2,
2002-05-27 17:25:30 +00:00
_("Co_lor:"), 1.0, 0.5,
button, 1, TRUE);
g_signal_connect (button, "color_changed",
G_CALLBACK (gimp_color_button_get_color),
&pvals.color);
g_signal_connect_swapped (button, "color_changed",
G_CALLBACK (nova),
drawable);
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 3,
changed "Number of Colors" to "Max Number of Colors" to clarify what this 2002-09-06 Michael Natterer <mitch@gimp.org> * app/gui/convert-dialog.c: changed "Number of Colors" to "Max Number of Colors" to clarify what this parameter does. (fixes #92194). * app/gui/menus.c: use GIMP_STOCK_INFO for "View/Info Window". Specify spibutton sizes in chars, not pixels (eek) all over the place. Also removed explicit sizes where the GtkSpinButton default size does not disturbe tabular widget layouts. * libgimpwidgets/gimpwidgets.c: removed the hardcoded width of 75 pixels in gimp_spin_button_new(). Changed gimp_scale_entry_new() and gimp_coordinates_new() to interpret their "spinbutton_width" parameters as chars if < 16, and as pixels otherwise. This gives reasonable results and doesn't cause unchanged plug-ins to suddenly have spinbuttons of dozens of chars width :) * libgimpwidgets/gimpsizeentry.c: added the same heuristic here. * libgimpwidgets/gimpquerybox.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/tools/gimpairbrushtool.c * app/tools/gimpblendtool.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbucketfilltool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpconvolvetool.c * app/tools/gimpdodgeburntool.c * app/tools/gimphuesaturationtool.c * app/tools/gimpinktool.c * app/tools/gimplevelstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpposterizetool.c * app/tools/gimpsmudgetool.c * app/tools/gimptexttool.c * app/tools/gimpthresholdtool.c * app/tools/paint_options.c * app/tools/selection_options.c * app/widgets/gimpbrusheditor.c * app/widgets/gimpbrushfactoryview.c * app/widgets/gimppaletteeditor.c: changed accordingly. * plug-ins/FractalExplorer/Dialogs.c * plug-ins/FractalExplorer/FractalExplorer.c * plug-ins/Lighting/lighting_ui.c * plug-ins/common/AlienMap.c * plug-ins/common/AlienMap2.c * plug-ins/common/CML_explorer.c * plug-ins/common/bumpmap.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/depthmerge.c * plug-ins/common/despeckle.c * plug-ins/common/diffraction.c * plug-ins/common/emboss.c * plug-ins/common/film.c * plug-ins/common/flarefx.c * plug-ins/common/fractaltrace.c * plug-ins/common/gauss_iir.c * plug-ins/common/gauss_rle.c * plug-ins/common/glasstile.c * plug-ins/common/grid.c * plug-ins/common/illusion.c * plug-ins/common/iwarp.c * plug-ins/common/jigsaw.c * plug-ins/common/lic.c * plug-ins/common/max_rgb.c * plug-ins/common/mblur.c * plug-ins/common/newsprint.c * plug-ins/common/nova.c * plug-ins/common/pixelize.c * plug-ins/common/sample_colorize.c * plug-ins/common/scatter_hsv.c * plug-ins/common/shift.c * plug-ins/common/sinus.c * plug-ins/common/sparkle.c * plug-ins/common/spread.c * plug-ins/common/tile.c * plug-ins/common/tileit.c * plug-ins/common/unsharp.c * plug-ins/common/vpropagate.c * plug-ins/common/waves.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/mosaic/mosaic.c * plug-ins/rcm/rcm_dialog.c: changed accordingly, which involves removals of gtk_widget_set_size_request(spinbutton), removal of lots of explicit spinbutton sizes in gimp_scale_entry_new(), and adding of new ones because GtkSpinButton's auto-size trashed tabular layouts. Lots of cleanup & indentation while browsing the plug-ins' code. Changed spacings, moved toggle buttons into frame titles, use stock items, stuff...
2002-09-06 20:44:47 +00:00
_("_Radius:"), SCALE_WIDTH, 8,
pvals.radius, 1, 100, 1, 10, 0,
FALSE, 1, GIMP_MAX_IMAGE_SIZE,
NULL, NULL);
g_signal_connect (adj, "value_changed",
G_CALLBACK (gimp_int_adjustment_update),
&pvals.radius);
g_signal_connect_swapped (adj, "value_changed",
G_CALLBACK (nova),
drawable);
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 4,
changed "Number of Colors" to "Max Number of Colors" to clarify what this 2002-09-06 Michael Natterer <mitch@gimp.org> * app/gui/convert-dialog.c: changed "Number of Colors" to "Max Number of Colors" to clarify what this parameter does. (fixes #92194). * app/gui/menus.c: use GIMP_STOCK_INFO for "View/Info Window". Specify spibutton sizes in chars, not pixels (eek) all over the place. Also removed explicit sizes where the GtkSpinButton default size does not disturbe tabular widget layouts. * libgimpwidgets/gimpwidgets.c: removed the hardcoded width of 75 pixels in gimp_spin_button_new(). Changed gimp_scale_entry_new() and gimp_coordinates_new() to interpret their "spinbutton_width" parameters as chars if < 16, and as pixels otherwise. This gives reasonable results and doesn't cause unchanged plug-ins to suddenly have spinbuttons of dozens of chars width :) * libgimpwidgets/gimpsizeentry.c: added the same heuristic here. * libgimpwidgets/gimpquerybox.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/tools/gimpairbrushtool.c * app/tools/gimpblendtool.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbucketfilltool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpconvolvetool.c * app/tools/gimpdodgeburntool.c * app/tools/gimphuesaturationtool.c * app/tools/gimpinktool.c * app/tools/gimplevelstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpposterizetool.c * app/tools/gimpsmudgetool.c * app/tools/gimptexttool.c * app/tools/gimpthresholdtool.c * app/tools/paint_options.c * app/tools/selection_options.c * app/widgets/gimpbrusheditor.c * app/widgets/gimpbrushfactoryview.c * app/widgets/gimppaletteeditor.c: changed accordingly. * plug-ins/FractalExplorer/Dialogs.c * plug-ins/FractalExplorer/FractalExplorer.c * plug-ins/Lighting/lighting_ui.c * plug-ins/common/AlienMap.c * plug-ins/common/AlienMap2.c * plug-ins/common/CML_explorer.c * plug-ins/common/bumpmap.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/depthmerge.c * plug-ins/common/despeckle.c * plug-ins/common/diffraction.c * plug-ins/common/emboss.c * plug-ins/common/film.c * plug-ins/common/flarefx.c * plug-ins/common/fractaltrace.c * plug-ins/common/gauss_iir.c * plug-ins/common/gauss_rle.c * plug-ins/common/glasstile.c * plug-ins/common/grid.c * plug-ins/common/illusion.c * plug-ins/common/iwarp.c * plug-ins/common/jigsaw.c * plug-ins/common/lic.c * plug-ins/common/max_rgb.c * plug-ins/common/mblur.c * plug-ins/common/newsprint.c * plug-ins/common/nova.c * plug-ins/common/pixelize.c * plug-ins/common/sample_colorize.c * plug-ins/common/scatter_hsv.c * plug-ins/common/shift.c * plug-ins/common/sinus.c * plug-ins/common/sparkle.c * plug-ins/common/spread.c * plug-ins/common/tile.c * plug-ins/common/tileit.c * plug-ins/common/unsharp.c * plug-ins/common/vpropagate.c * plug-ins/common/waves.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/mosaic/mosaic.c * plug-ins/rcm/rcm_dialog.c: changed accordingly, which involves removals of gtk_widget_set_size_request(spinbutton), removal of lots of explicit spinbutton sizes in gimp_scale_entry_new(), and adding of new ones because GtkSpinButton's auto-size trashed tabular layouts. Lots of cleanup & indentation while browsing the plug-ins' code. Changed spacings, moved toggle buttons into frame titles, use stock items, stuff...
2002-09-06 20:44:47 +00:00
_("_Spokes:"), SCALE_WIDTH, 8,
pvals.nspoke, 1, 1024, 1, 16, 0,
TRUE, 0, 0,
NULL, NULL);
g_signal_connect (adj, "value_changed",
G_CALLBACK (gimp_int_adjustment_update),
&pvals.nspoke);
g_signal_connect_swapped (adj, "value_changed",
G_CALLBACK (nova),
drawable);
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 5,
changed "Number of Colors" to "Max Number of Colors" to clarify what this 2002-09-06 Michael Natterer <mitch@gimp.org> * app/gui/convert-dialog.c: changed "Number of Colors" to "Max Number of Colors" to clarify what this parameter does. (fixes #92194). * app/gui/menus.c: use GIMP_STOCK_INFO for "View/Info Window". Specify spibutton sizes in chars, not pixels (eek) all over the place. Also removed explicit sizes where the GtkSpinButton default size does not disturbe tabular widget layouts. * libgimpwidgets/gimpwidgets.c: removed the hardcoded width of 75 pixels in gimp_spin_button_new(). Changed gimp_scale_entry_new() and gimp_coordinates_new() to interpret their "spinbutton_width" parameters as chars if < 16, and as pixels otherwise. This gives reasonable results and doesn't cause unchanged plug-ins to suddenly have spinbuttons of dozens of chars width :) * libgimpwidgets/gimpsizeentry.c: added the same heuristic here. * libgimpwidgets/gimpquerybox.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/tools/gimpairbrushtool.c * app/tools/gimpblendtool.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbucketfilltool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpconvolvetool.c * app/tools/gimpdodgeburntool.c * app/tools/gimphuesaturationtool.c * app/tools/gimpinktool.c * app/tools/gimplevelstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpposterizetool.c * app/tools/gimpsmudgetool.c * app/tools/gimptexttool.c * app/tools/gimpthresholdtool.c * app/tools/paint_options.c * app/tools/selection_options.c * app/widgets/gimpbrusheditor.c * app/widgets/gimpbrushfactoryview.c * app/widgets/gimppaletteeditor.c: changed accordingly. * plug-ins/FractalExplorer/Dialogs.c * plug-ins/FractalExplorer/FractalExplorer.c * plug-ins/Lighting/lighting_ui.c * plug-ins/common/AlienMap.c * plug-ins/common/AlienMap2.c * plug-ins/common/CML_explorer.c * plug-ins/common/bumpmap.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/depthmerge.c * plug-ins/common/despeckle.c * plug-ins/common/diffraction.c * plug-ins/common/emboss.c * plug-ins/common/film.c * plug-ins/common/flarefx.c * plug-ins/common/fractaltrace.c * plug-ins/common/gauss_iir.c * plug-ins/common/gauss_rle.c * plug-ins/common/glasstile.c * plug-ins/common/grid.c * plug-ins/common/illusion.c * plug-ins/common/iwarp.c * plug-ins/common/jigsaw.c * plug-ins/common/lic.c * plug-ins/common/max_rgb.c * plug-ins/common/mblur.c * plug-ins/common/newsprint.c * plug-ins/common/nova.c * plug-ins/common/pixelize.c * plug-ins/common/sample_colorize.c * plug-ins/common/scatter_hsv.c * plug-ins/common/shift.c * plug-ins/common/sinus.c * plug-ins/common/sparkle.c * plug-ins/common/spread.c * plug-ins/common/tile.c * plug-ins/common/tileit.c * plug-ins/common/unsharp.c * plug-ins/common/vpropagate.c * plug-ins/common/waves.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/mosaic/mosaic.c * plug-ins/rcm/rcm_dialog.c: changed accordingly, which involves removals of gtk_widget_set_size_request(spinbutton), removal of lots of explicit spinbutton sizes in gimp_scale_entry_new(), and adding of new ones because GtkSpinButton's auto-size trashed tabular layouts. Lots of cleanup & indentation while browsing the plug-ins' code. Changed spacings, moved toggle buttons into frame titles, use stock items, stuff...
2002-09-06 20:44:47 +00:00
_("R_andom Hue:"), SCALE_WIDTH, 8,
pvals.randomhue, 0, 360, 1, 15, 0,
TRUE, 0, 0,
NULL, NULL);
g_signal_connect (adj, "value_changed",
G_CALLBACK (gimp_int_adjustment_update),
&pvals.randomhue);
g_signal_connect_swapped (adj, "value_changed",
G_CALLBACK (nova),
drawable);
1997-11-24 22:05:25 +00:00
gtk_widget_show (frame);
gtk_widget_show (table);
gtk_widget_show (dlg);
gtk_main ();
gdk_flush ();
return pint.run;
}
static void
nova_ok_callback (GtkWidget *widget,
gpointer data)
1997-11-24 22:05:25 +00:00
{
pint.run = TRUE;
1997-11-24 22:05:25 +00:00
gtk_widget_destroy (GTK_WIDGET (data));
}
/*=================================================================
CenterFrame
A frame that contains one preview and 2 entrys, used for positioning
of the center of Nova.
==================================================================*/
/*
* Create new CenterFrame, and return it (GtkFrame).
*/
static GtkWidget *
nova_center_create (GimpDrawable *drawable)
1997-11-24 22:05:25 +00:00
{
NovaCenter *center;
GtkWidget *frame;
GtkWidget *table;
GtkWidget *label;
GtkWidget *pframe;
GtkWidget *spinbutton;
GtkWidget *check;
center = g_new (NovaCenter, 1);
1997-11-24 22:05:25 +00:00
center->drawable = drawable;
center->dwidth = gimp_drawable_width (drawable->drawable_id);
center->dheight = gimp_drawable_height (drawable->drawable_id);
center->bpp = gimp_drawable_bpp (drawable->drawable_id);
if (gimp_drawable_has_alpha (drawable->drawable_id))
1997-11-24 22:05:25 +00:00
center->bpp--;
center->cursor = FALSE;
center->curx = 0;
center->cury = 0;
center->oldx = 0;
center->oldy = 0;
center->in_call = TRUE; /* to avoid side effects while initialization */
1997-11-24 22:05:25 +00:00
frame = gtk_frame_new (_("Center of SuperNova"));
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
gtk_container_set_border_width (GTK_CONTAINER (frame), 4);
g_signal_connect (frame, "destroy",
G_CALLBACK (nova_center_destroy),
center);
table = gtk_table_new (3, 4, FALSE);
gtk_table_set_row_spacings (GTK_TABLE (table), 4);
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
gtk_table_set_col_spacing (GTK_TABLE (table), 1, 6);
gtk_container_set_border_width (GTK_CONTAINER (table), 4);
1997-11-24 22:05:25 +00:00
gtk_container_add (GTK_CONTAINER (frame), table);
2002-05-27 17:25:30 +00:00
label = gtk_label_new_with_mnemonic (_("_X:"));
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1,
GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (label);
spinbutton =
gimp_spin_button_new (&center->xadj,
pvals.xcenter, G_MININT, G_MAXINT,
1, 10, 10, 0, 0);
gtk_table_attach (GTK_TABLE (table), spinbutton, 1, 2, 0, 1,
GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (spinbutton);
2002-05-27 17:25:30 +00:00
gtk_label_set_mnemonic_widget (GTK_LABEL (label), spinbutton);
g_object_set_data (G_OBJECT (center->xadj), "center", center);
g_signal_connect (center->xadj, "value_changed",
G_CALLBACK (nova_center_adjustment_update),
&pvals.xcenter);
2002-05-27 17:25:30 +00:00
label = gtk_label_new_with_mnemonic (_("_Y:"));
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label, 2, 3, 0, 1,
GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (label);
spinbutton =
gimp_spin_button_new (&center->yadj,
pvals.ycenter, G_MININT, G_MAXINT,
1, 10, 10, 0, 0);
gtk_table_attach (GTK_TABLE (table), spinbutton, 3, 4, 0, 1,
GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (spinbutton);
2002-05-27 17:25:30 +00:00
gtk_label_set_mnemonic_widget (GTK_LABEL (label), spinbutton);
g_object_set_data (G_OBJECT (center->yadj), "center", center);
g_signal_connect (center->yadj, "value_changed",
G_CALLBACK (nova_center_adjustment_update),
&pvals.ycenter);
/* frame that contains preview */
pframe = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (pframe), GTK_SHADOW_IN);
gtk_table_attach (GTK_TABLE (table), pframe, 0, 4, 1, 2,
0, 0, 0, 0);
1997-11-24 22:05:25 +00:00
/* PREVIEW */
preview = gimp_fixme_preview_new (drawable, FALSE);
gtk_widget_set_events (preview->widget, PREVIEW_MASK);
gtk_container_add (GTK_CONTAINER (pframe), preview->widget);
gtk_widget_show (preview->widget);
1997-11-24 22:05:25 +00:00
g_signal_connect_after (preview->widget, "expose_event",
G_CALLBACK (nova_center_preview_expose),
center);
g_signal_connect (preview->widget, "event",
G_CALLBACK (nova_center_preview_events),
center);
gtk_widget_show (pframe);
gtk_widget_show (table);
g_object_set_data (G_OBJECT (frame), "center", center);
gtk_widget_show (frame);
1997-11-24 22:05:25 +00:00
check = gtk_check_button_new_with_mnemonic (_("S_how Cursor"));
gtk_table_attach (GTK_TABLE (table), check, 0, 4, 2, 3,
GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), show_cursor);
gtk_widget_show (check);
g_signal_connect (check, "toggled",
G_CALLBACK (gimp_toggle_button_update),
&show_cursor);
g_signal_connect_swapped (check, "toggled",
G_CALLBACK (nova),
drawable);
nova_center_cursor_update (center);
1997-11-24 22:05:25 +00:00
center->cursor = FALSE; /* Make sure that the cursor has not been drawn */
1997-11-24 22:05:25 +00:00
center->in_call = FALSE; /* End of initialization */
nova (drawable, TRUE);
1997-11-24 22:05:25 +00:00
return frame;
}
static void
nova_center_destroy (GtkWidget *widget,
gpointer data)
1997-11-24 22:05:25 +00:00
{
NovaCenter *center = data;
g_free (center);
1997-11-24 22:05:25 +00:00
}
/*
* Drawing CenterFrame
* if update & PREVIEW, draw preview
* if update & CURSOR, draw cross cursor
*/
static void
nova_center_draw (NovaCenter *center,
gint update)
1997-11-24 22:05:25 +00:00
{
GtkWidget *prvw = preview->widget;
if (update & PREVIEW)
1997-11-24 22:05:25 +00:00
{
center->cursor = FALSE;
}
if (update & CURSOR)
1997-11-24 22:05:25 +00:00
{
gdk_gc_set_function (prvw->style->black_gc, GDK_INVERT);
if (show_cursor)
{
if (center->cursor)
{
gdk_draw_line (prvw->window,
prvw->style->black_gc,
center->oldx, 1, center->oldx,
preview->height - 1);
gdk_draw_line (prvw->window,
prvw->style->black_gc,
1, center->oldy,
preview->width - 1, center->oldy);
}
gdk_draw_line (prvw->window,
prvw->style->black_gc,
center->curx, 1, center->curx,
preview->height - 1);
gdk_draw_line (prvw->window,
prvw->style->black_gc,
1, center->cury,
preview->width - 1, center->cury);
}
1997-11-24 22:05:25 +00:00
/* current position of cursor is updated */
center->oldx = center->curx;
center->oldy = center->cury;
center->cursor = TRUE;
gdk_gc_set_function (prvw->style->black_gc, GDK_COPY);
1997-11-24 22:05:25 +00:00
}
}
/*
* CenterFrame entry callback
*/
static void
nova_center_adjustment_update (GtkAdjustment *adjustment,
gpointer data)
1997-11-24 22:05:25 +00:00
{
NovaCenter *center;
gimp_int_adjustment_update (adjustment, data);
center = g_object_get_data (G_OBJECT (adjustment), "center");
1997-11-24 22:05:25 +00:00
if (!center->in_call)
1997-11-24 22:05:25 +00:00
{
nova_center_cursor_update (center);
nova_center_draw (center, CURSOR);
nova (center->drawable, TRUE);
1997-11-24 22:05:25 +00:00
}
}
/*
* Update the cross cursor's coordinates accoding to pvals.[xy]center
* but not redraw it
*/
static void
nova_center_cursor_update (NovaCenter *center)
1997-11-24 22:05:25 +00:00
{
center->curx = pvals.xcenter * preview->width / center->dwidth;
center->cury = pvals.ycenter * preview->height / center->dheight;
center->curx = CLAMP (center->curx, 0, preview->width - 1);
center->cury = CLAMP (center->cury, 0, preview->height - 1);
1997-11-24 22:05:25 +00:00
}
/*
* Handle the expose event on the preview
*/
static gint
nova_center_preview_expose (GtkWidget *widget,
GdkEvent *event,
gpointer data)
1997-11-24 22:05:25 +00:00
{
printf("Before\n");
nova_center_draw ((NovaCenter*) data, ALL);
printf("After\n");
1997-11-24 22:05:25 +00:00
return FALSE;
}
/*
* Handle other events on the preview
*/
static gint
nova_center_preview_events (GtkWidget *widget,
GdkEvent *event,
gpointer data)
1997-11-24 22:05:25 +00:00
{
NovaCenter *center;
GdkEventButton *bevent;
GdkEventMotion *mevent;
center = (NovaCenter *) data;
1997-11-24 22:05:25 +00:00
switch (event->type)
{
case GDK_EXPOSE:
break;
case GDK_BUTTON_PRESS:
bevent = (GdkEventButton *) event;
center->curx = bevent->x;
center->cury = bevent->y;
goto mouse;
case GDK_MOTION_NOTIFY:
mevent = (GdkEventMotion *) event;
if (!mevent->state)
break;
1997-11-24 22:05:25 +00:00
center->curx = mevent->x;
center->cury = mevent->y;
mouse:
nova_center_draw (center, CURSOR);
1997-11-24 22:05:25 +00:00
center->in_call = TRUE;
gtk_adjustment_set_value (GTK_ADJUSTMENT (center->xadj),
center->curx * center->dwidth /
preview->width);
gtk_adjustment_set_value (GTK_ADJUSTMENT (center->yadj),
center->cury * center->dheight /
preview->height);
1997-11-24 22:05:25 +00:00
center->in_call = FALSE;
nova (center->drawable, 1);
1997-11-24 22:05:25 +00:00
break;
default:
break;
}
return FALSE;
}
/*
################################################################
## ##
## Main Calculation ##
## ##
################################################################
1997-11-24 22:05:25 +00:00
*/
configure.in po-plug-ins/POTFILES.in plug-ins/common/Makefile.am 2000-01-25 Michael Natterer <mitch@gimp.org> * configure.in * po-plug-ins/POTFILES.in * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/megawidget/*: removed. (There were only 3 functions left which were used by ~5 plugins, so I moved the resp. functions to the plugins). More preview stuff to come... * app/airbrush_blob.c * modules/colorsel_triangle.c * modules/colorsel_water.c: use G_PI instead of M_PI. * app/procedural_db.h * libgimp/gimpenums.h * plug-ins/script-fu/script-fu-constants.c * tools/pdbgen/enums.pl: new PDB return value STATUS_CANCEL which indicates that "Cancel" was pressed in a plugin dialog. (Useful only for file load/save plugins). * app/fileops.[ch] * app/menus.c: changes to handle STATUS_CANCEL correctly. Did some code cleanup in fileops.[ch]. Pop up a warning if File->Save failed. * app/plug_in.c: return_val[0] is of type PDB_STATUS, not PDB_INT32. * libgimp/gimpmath.h: new constant G_MAXRAND which equals to RAND_MAX if it exists or to G_MAXINT otherwise. * libgimp/gimpwidgets.[ch]: new function gimp_random_seed_new() which creates a spinbutton and a "Time" toggle. Call the function which does the "set_sensitive" magic from the radio button callback. * plug-ins/[75 plugins]: - Return STATUS_CANCEL in all file load/save dialogs if "Cancel" was pressed. - Standardized the file plugins' "run" functions. - Use G_PI and G_MAXRAND everywhere. - Added tons of scales and spinbuttons instead of text entries. - Applied uniform packing/spacings all over the place. - Reorganized some UIs (stuff like moving the preview to the top left corner of the dialog). - Removed many ui helper functions and callbacks and use the stuff from libgimp instead. - I tried not to restrict the range of possible values when I replaced entries with spinbuttons/scales but may have failed, though in some cases. Please test ;-) - #include <libgimp/gimpmath.h> where appropriate and use it's constants. - Indentation, s/int/gint/ et.al., code cleanup. RFC: The plugins are definitely not useable with GIMP 1.0 any more, so shouldn't we remove all the remaining compatibility stuff ??? (like "#ifdef GIMP_HAVE_PARASITES")
2000-01-25 17:46:56 +00:00
static gdouble
configure.in app/core/gimpbrushpipe.c app/gui/about-dialog.c 2002-11-20 Dave Neary <bolsh@gimp.org> * configure.in * app/core/gimpbrushpipe.c * app/gui/about-dialog.c * app/paint-funcs/paint-funcs-generic.h * app/paint-funcs/paint-funcs.c * libgimpmath/gimpmath.h * libgimpwidgets/gimpwidgets.c * plug-ins/common/CML_explorer.c * plug-ins/common/blur.c * plug-ins/common/cubism.c * plug-ins/common/gee.c * plug-ins/common/gee_zoom.c * plug-ins/common/gqbist.c * plug-ins/common/jigsaw.c * plug-ins/common/lic.c * plug-ins/common/noisify.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/plasma.c * plug-ins/common/randomize.c * plug-ins/common/sample_colorize.c * plug-ins/common/scatter_hsv.c * plug-ins/common/shift.c * plug-ins/common/sinus.c * plug-ins/common/smooth_palette.c * plug-ins/common/snoise.c * plug-ins/common/sparkle.c * plug-ins/common/spheredesigner.c * plug-ins/common/spread.c * plug-ins/common/warp.c * plug-ins/common/wind.c * plug-ins/flame/cmap.c * plug-ins/flame/flame.c * plug-ins/flame/libifs.c * plug-ins/gflare/gflare.c * plug-ins/gimpressionist/gimpressionist.c * plug-ins/gimpressionist/gimpressionist.h * plug-ins/gimpressionist/plasma.c * plug-ins/gimpressionist/repaint.c * plug-ins/ifscompose/ifscompose_utils.c * plug-ins/maze/algorithms.c * plug-ins/maze/maze.c * plug-ins/maze/maze.h * plug-ins/mosaic/mosaic.c: Change all occurrences of RAND_MAX, G_MAXRAND, rand(), srand(), lrand48(), srand48(), random(), srandom(), RAND_FUNC and SRAND_FUNC to the appropriate g_rand* equivalent. Programs which require seed setting for reproducible results, and anything in the core, gets a dedicated GRand * for the lifetime required. Programs which only ever used random numbers for tossing a coin, rolling a dice, etc use g_random functions. For the rest, judgement was used. Where it was easy, a GRand * object was used and g_rand_* functions were preferred. This fixes bug #67386 in HEAD.
2002-11-20 09:27:48 +00:00
gauss (GRand *gr)
2000-01-09 15:51:46 +00:00
{
configure.in po-plug-ins/POTFILES.in plug-ins/common/Makefile.am 2000-01-25 Michael Natterer <mitch@gimp.org> * configure.in * po-plug-ins/POTFILES.in * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/megawidget/*: removed. (There were only 3 functions left which were used by ~5 plugins, so I moved the resp. functions to the plugins). More preview stuff to come... * app/airbrush_blob.c * modules/colorsel_triangle.c * modules/colorsel_water.c: use G_PI instead of M_PI. * app/procedural_db.h * libgimp/gimpenums.h * plug-ins/script-fu/script-fu-constants.c * tools/pdbgen/enums.pl: new PDB return value STATUS_CANCEL which indicates that "Cancel" was pressed in a plugin dialog. (Useful only for file load/save plugins). * app/fileops.[ch] * app/menus.c: changes to handle STATUS_CANCEL correctly. Did some code cleanup in fileops.[ch]. Pop up a warning if File->Save failed. * app/plug_in.c: return_val[0] is of type PDB_STATUS, not PDB_INT32. * libgimp/gimpmath.h: new constant G_MAXRAND which equals to RAND_MAX if it exists or to G_MAXINT otherwise. * libgimp/gimpwidgets.[ch]: new function gimp_random_seed_new() which creates a spinbutton and a "Time" toggle. Call the function which does the "set_sensitive" magic from the radio button callback. * plug-ins/[75 plugins]: - Return STATUS_CANCEL in all file load/save dialogs if "Cancel" was pressed. - Standardized the file plugins' "run" functions. - Use G_PI and G_MAXRAND everywhere. - Added tons of scales and spinbuttons instead of text entries. - Applied uniform packing/spacings all over the place. - Reorganized some UIs (stuff like moving the preview to the top left corner of the dialog). - Removed many ui helper functions and callbacks and use the stuff from libgimp instead. - I tried not to restrict the range of possible values when I replaced entries with spinbuttons/scales but may have failed, though in some cases. Please test ;-) - #include <libgimp/gimpmath.h> where appropriate and use it's constants. - Indentation, s/int/gint/ et.al., code cleanup. RFC: The plugins are definitely not useable with GIMP 1.0 any more, so shouldn't we remove all the remaining compatibility stuff ??? (like "#ifdef GIMP_HAVE_PARASITES")
2000-01-25 17:46:56 +00:00
gdouble sum = 0;
gint i;
for (i = 0; i < 6; i++)
configure.in app/core/gimpbrushpipe.c app/gui/about-dialog.c 2002-11-20 Dave Neary <bolsh@gimp.org> * configure.in * app/core/gimpbrushpipe.c * app/gui/about-dialog.c * app/paint-funcs/paint-funcs-generic.h * app/paint-funcs/paint-funcs.c * libgimpmath/gimpmath.h * libgimpwidgets/gimpwidgets.c * plug-ins/common/CML_explorer.c * plug-ins/common/blur.c * plug-ins/common/cubism.c * plug-ins/common/gee.c * plug-ins/common/gee_zoom.c * plug-ins/common/gqbist.c * plug-ins/common/jigsaw.c * plug-ins/common/lic.c * plug-ins/common/noisify.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/plasma.c * plug-ins/common/randomize.c * plug-ins/common/sample_colorize.c * plug-ins/common/scatter_hsv.c * plug-ins/common/shift.c * plug-ins/common/sinus.c * plug-ins/common/smooth_palette.c * plug-ins/common/snoise.c * plug-ins/common/sparkle.c * plug-ins/common/spheredesigner.c * plug-ins/common/spread.c * plug-ins/common/warp.c * plug-ins/common/wind.c * plug-ins/flame/cmap.c * plug-ins/flame/flame.c * plug-ins/flame/libifs.c * plug-ins/gflare/gflare.c * plug-ins/gimpressionist/gimpressionist.c * plug-ins/gimpressionist/gimpressionist.h * plug-ins/gimpressionist/plasma.c * plug-ins/gimpressionist/repaint.c * plug-ins/ifscompose/ifscompose_utils.c * plug-ins/maze/algorithms.c * plug-ins/maze/maze.c * plug-ins/maze/maze.h * plug-ins/mosaic/mosaic.c: Change all occurrences of RAND_MAX, G_MAXRAND, rand(), srand(), lrand48(), srand48(), random(), srandom(), RAND_FUNC and SRAND_FUNC to the appropriate g_rand* equivalent. Programs which require seed setting for reproducible results, and anything in the core, gets a dedicated GRand * for the lifetime required. Programs which only ever used random numbers for tossing a coin, rolling a dice, etc use g_random functions. For the rest, judgement was used. Where it was easy, a GRand * object was used and g_rand_* functions were preferred. This fixes bug #67386 in HEAD.
2002-11-20 09:27:48 +00:00
sum += (gdouble) g_rand_double (gr);
configure.in po-plug-ins/POTFILES.in plug-ins/common/Makefile.am 2000-01-25 Michael Natterer <mitch@gimp.org> * configure.in * po-plug-ins/POTFILES.in * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/megawidget/*: removed. (There were only 3 functions left which were used by ~5 plugins, so I moved the resp. functions to the plugins). More preview stuff to come... * app/airbrush_blob.c * modules/colorsel_triangle.c * modules/colorsel_water.c: use G_PI instead of M_PI. * app/procedural_db.h * libgimp/gimpenums.h * plug-ins/script-fu/script-fu-constants.c * tools/pdbgen/enums.pl: new PDB return value STATUS_CANCEL which indicates that "Cancel" was pressed in a plugin dialog. (Useful only for file load/save plugins). * app/fileops.[ch] * app/menus.c: changes to handle STATUS_CANCEL correctly. Did some code cleanup in fileops.[ch]. Pop up a warning if File->Save failed. * app/plug_in.c: return_val[0] is of type PDB_STATUS, not PDB_INT32. * libgimp/gimpmath.h: new constant G_MAXRAND which equals to RAND_MAX if it exists or to G_MAXINT otherwise. * libgimp/gimpwidgets.[ch]: new function gimp_random_seed_new() which creates a spinbutton and a "Time" toggle. Call the function which does the "set_sensitive" magic from the radio button callback. * plug-ins/[75 plugins]: - Return STATUS_CANCEL in all file load/save dialogs if "Cancel" was pressed. - Standardized the file plugins' "run" functions. - Use G_PI and G_MAXRAND everywhere. - Added tons of scales and spinbuttons instead of text entries. - Applied uniform packing/spacings all over the place. - Reorganized some UIs (stuff like moving the preview to the top left corner of the dialog). - Removed many ui helper functions and callbacks and use the stuff from libgimp instead. - I tried not to restrict the range of possible values when I replaced entries with spinbuttons/scales but may have failed, though in some cases. Please test ;-) - #include <libgimp/gimpmath.h> where appropriate and use it's constants. - Indentation, s/int/gint/ et.al., code cleanup. RFC: The plugins are definitely not useable with GIMP 1.0 any more, so shouldn't we remove all the remaining compatibility stuff ??? (like "#ifdef GIMP_HAVE_PARASITES")
2000-01-25 17:46:56 +00:00
return sum / 6;
2000-01-09 15:51:46 +00:00
}
static void
nova (GimpDrawable *drawable,
gboolean preview_mode)
2000-01-09 15:51:46 +00:00
{
GimpPixelRgn src_rgn;
GimpPixelRgn dest_rgn;
guchar *src_row, *dest_row;
guchar *src, *dest;
gint x1, y1, x2, y2;
gint row, col;
gint x, y;
gint alpha, bpp;
gint progress, max_progress;
gboolean has_alpha;
gint xc, yc; /* center of nova */
gdouble u, v;
gdouble l;
gdouble w, w1, c;
gdouble *spoke;
gdouble nova_alpha;
GimpRGB color;
GimpRGB src_color;
GimpRGB *spokecolor;
GimpHSV hsv;
gint i;
configure.in app/core/gimpbrushpipe.c app/gui/about-dialog.c 2002-11-20 Dave Neary <bolsh@gimp.org> * configure.in * app/core/gimpbrushpipe.c * app/gui/about-dialog.c * app/paint-funcs/paint-funcs-generic.h * app/paint-funcs/paint-funcs.c * libgimpmath/gimpmath.h * libgimpwidgets/gimpwidgets.c * plug-ins/common/CML_explorer.c * plug-ins/common/blur.c * plug-ins/common/cubism.c * plug-ins/common/gee.c * plug-ins/common/gee_zoom.c * plug-ins/common/gqbist.c * plug-ins/common/jigsaw.c * plug-ins/common/lic.c * plug-ins/common/noisify.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/plasma.c * plug-ins/common/randomize.c * plug-ins/common/sample_colorize.c * plug-ins/common/scatter_hsv.c * plug-ins/common/shift.c * plug-ins/common/sinus.c * plug-ins/common/smooth_palette.c * plug-ins/common/snoise.c * plug-ins/common/sparkle.c * plug-ins/common/spheredesigner.c * plug-ins/common/spread.c * plug-ins/common/warp.c * plug-ins/common/wind.c * plug-ins/flame/cmap.c * plug-ins/flame/flame.c * plug-ins/flame/libifs.c * plug-ins/gflare/gflare.c * plug-ins/gimpressionist/gimpressionist.c * plug-ins/gimpressionist/gimpressionist.h * plug-ins/gimpressionist/plasma.c * plug-ins/gimpressionist/repaint.c * plug-ins/ifscompose/ifscompose_utils.c * plug-ins/maze/algorithms.c * plug-ins/maze/maze.c * plug-ins/maze/maze.h * plug-ins/mosaic/mosaic.c: Change all occurrences of RAND_MAX, G_MAXRAND, rand(), srand(), lrand48(), srand48(), random(), srandom(), RAND_FUNC and SRAND_FUNC to the appropriate g_rand* equivalent. Programs which require seed setting for reproducible results, and anything in the core, gets a dedicated GRand * for the lifetime required. Programs which only ever used random numbers for tossing a coin, rolling a dice, etc use g_random functions. For the rest, judgement was used. Where it was easy, a GRand * object was used and g_rand_* functions were preferred. This fixes bug #67386 in HEAD.
2002-11-20 09:27:48 +00:00
GRand *gr;
configure.in app/core/gimpbrushpipe.c app/gui/about-dialog.c 2002-11-20 Dave Neary <bolsh@gimp.org> * configure.in * app/core/gimpbrushpipe.c * app/gui/about-dialog.c * app/paint-funcs/paint-funcs-generic.h * app/paint-funcs/paint-funcs.c * libgimpmath/gimpmath.h * libgimpwidgets/gimpwidgets.c * plug-ins/common/CML_explorer.c * plug-ins/common/blur.c * plug-ins/common/cubism.c * plug-ins/common/gee.c * plug-ins/common/gee_zoom.c * plug-ins/common/gqbist.c * plug-ins/common/jigsaw.c * plug-ins/common/lic.c * plug-ins/common/noisify.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/plasma.c * plug-ins/common/randomize.c * plug-ins/common/sample_colorize.c * plug-ins/common/scatter_hsv.c * plug-ins/common/shift.c * plug-ins/common/sinus.c * plug-ins/common/smooth_palette.c * plug-ins/common/snoise.c * plug-ins/common/sparkle.c * plug-ins/common/spheredesigner.c * plug-ins/common/spread.c * plug-ins/common/warp.c * plug-ins/common/wind.c * plug-ins/flame/cmap.c * plug-ins/flame/flame.c * plug-ins/flame/libifs.c * plug-ins/gflare/gflare.c * plug-ins/gimpressionist/gimpressionist.c * plug-ins/gimpressionist/gimpressionist.h * plug-ins/gimpressionist/plasma.c * plug-ins/gimpressionist/repaint.c * plug-ins/ifscompose/ifscompose_utils.c * plug-ins/maze/algorithms.c * plug-ins/maze/maze.c * plug-ins/maze/maze.h * plug-ins/mosaic/mosaic.c: Change all occurrences of RAND_MAX, G_MAXRAND, rand(), srand(), lrand48(), srand48(), random(), srandom(), RAND_FUNC and SRAND_FUNC to the appropriate g_rand* equivalent. Programs which require seed setting for reproducible results, and anything in the core, gets a dedicated GRand * for the lifetime required. Programs which only ever used random numbers for tossing a coin, rolling a dice, etc use g_random functions. For the rest, judgement was used. Where it was easy, a GRand * object was used and g_rand_* functions were preferred. This fixes bug #67386 in HEAD.
2002-11-20 09:27:48 +00:00
gr = g_rand_new ();
1999-09-03 23:14:44 +00:00
/* initialize */
has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
1999-09-03 23:14:44 +00:00
spoke = g_new (gdouble, pvals.nspoke);
spokecolor = g_new (GimpRGB, pvals.nspoke);
1999-09-03 23:14:44 +00:00
gimp_rgb_set_alpha (&pvals.color, 1.0);
gimp_rgb_to_hsv (&pvals.color, &hsv);
1999-09-03 23:14:44 +00:00
for (i = 0; i < pvals.nspoke; i++)
{
configure.in app/core/gimpbrushpipe.c app/gui/about-dialog.c 2002-11-20 Dave Neary <bolsh@gimp.org> * configure.in * app/core/gimpbrushpipe.c * app/gui/about-dialog.c * app/paint-funcs/paint-funcs-generic.h * app/paint-funcs/paint-funcs.c * libgimpmath/gimpmath.h * libgimpwidgets/gimpwidgets.c * plug-ins/common/CML_explorer.c * plug-ins/common/blur.c * plug-ins/common/cubism.c * plug-ins/common/gee.c * plug-ins/common/gee_zoom.c * plug-ins/common/gqbist.c * plug-ins/common/jigsaw.c * plug-ins/common/lic.c * plug-ins/common/noisify.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/plasma.c * plug-ins/common/randomize.c * plug-ins/common/sample_colorize.c * plug-ins/common/scatter_hsv.c * plug-ins/common/shift.c * plug-ins/common/sinus.c * plug-ins/common/smooth_palette.c * plug-ins/common/snoise.c * plug-ins/common/sparkle.c * plug-ins/common/spheredesigner.c * plug-ins/common/spread.c * plug-ins/common/warp.c * plug-ins/common/wind.c * plug-ins/flame/cmap.c * plug-ins/flame/flame.c * plug-ins/flame/libifs.c * plug-ins/gflare/gflare.c * plug-ins/gimpressionist/gimpressionist.c * plug-ins/gimpressionist/gimpressionist.h * plug-ins/gimpressionist/plasma.c * plug-ins/gimpressionist/repaint.c * plug-ins/ifscompose/ifscompose_utils.c * plug-ins/maze/algorithms.c * plug-ins/maze/maze.c * plug-ins/maze/maze.h * plug-ins/mosaic/mosaic.c: Change all occurrences of RAND_MAX, G_MAXRAND, rand(), srand(), lrand48(), srand48(), random(), srandom(), RAND_FUNC and SRAND_FUNC to the appropriate g_rand* equivalent. Programs which require seed setting for reproducible results, and anything in the core, gets a dedicated GRand * for the lifetime required. Programs which only ever used random numbers for tossing a coin, rolling a dice, etc use g_random functions. For the rest, judgement was used. Where it was easy, a GRand * object was used and g_rand_* functions were preferred. This fixes bug #67386 in HEAD.
2002-11-20 09:27:48 +00:00
spoke[i] = gauss (gr);
hsv.h += ((gdouble) pvals.randomhue / 360.0) *
configure.in app/core/gimpbrushpipe.c app/gui/about-dialog.c 2002-11-20 Dave Neary <bolsh@gimp.org> * configure.in * app/core/gimpbrushpipe.c * app/gui/about-dialog.c * app/paint-funcs/paint-funcs-generic.h * app/paint-funcs/paint-funcs.c * libgimpmath/gimpmath.h * libgimpwidgets/gimpwidgets.c * plug-ins/common/CML_explorer.c * plug-ins/common/blur.c * plug-ins/common/cubism.c * plug-ins/common/gee.c * plug-ins/common/gee_zoom.c * plug-ins/common/gqbist.c * plug-ins/common/jigsaw.c * plug-ins/common/lic.c * plug-ins/common/noisify.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/plasma.c * plug-ins/common/randomize.c * plug-ins/common/sample_colorize.c * plug-ins/common/scatter_hsv.c * plug-ins/common/shift.c * plug-ins/common/sinus.c * plug-ins/common/smooth_palette.c * plug-ins/common/snoise.c * plug-ins/common/sparkle.c * plug-ins/common/spheredesigner.c * plug-ins/common/spread.c * plug-ins/common/warp.c * plug-ins/common/wind.c * plug-ins/flame/cmap.c * plug-ins/flame/flame.c * plug-ins/flame/libifs.c * plug-ins/gflare/gflare.c * plug-ins/gimpressionist/gimpressionist.c * plug-ins/gimpressionist/gimpressionist.h * plug-ins/gimpressionist/plasma.c * plug-ins/gimpressionist/repaint.c * plug-ins/ifscompose/ifscompose_utils.c * plug-ins/maze/algorithms.c * plug-ins/maze/maze.c * plug-ins/maze/maze.h * plug-ins/mosaic/mosaic.c: Change all occurrences of RAND_MAX, G_MAXRAND, rand(), srand(), lrand48(), srand48(), random(), srandom(), RAND_FUNC and SRAND_FUNC to the appropriate g_rand* equivalent. Programs which require seed setting for reproducible results, and anything in the core, gets a dedicated GRand * for the lifetime required. Programs which only ever used random numbers for tossing a coin, rolling a dice, etc use g_random functions. For the rest, judgement was used. Where it was easy, a GRand * object was used and g_rand_* functions were preferred. This fixes bug #67386 in HEAD.
2002-11-20 09:27:48 +00:00
g_rand_double_range (gr, -0.5, 0.5);
if (hsv.h < 0)
hsv.h += 1.0;
else if (hsv.h >= 1.0)
hsv.h -= 1.0;
gimp_hsv_to_rgb (&hsv, spokecolor + i);
}
if (preview_mode)
{
xc = (gdouble) pvals.xcenter * preview->scale_x;
yc = (gdouble) pvals.ycenter * preview->scale_y;
x1 = y1 = 0;
x2 = preview->width;
y2 = preview->height;
bpp = preview->bpp;
has_alpha = FALSE;
alpha = bpp;
}
else
{
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
bpp = gimp_drawable_bpp (drawable->drawable_id);
alpha = (has_alpha) ? bpp - 1 : bpp;
xc = pvals.xcenter;
yc = pvals.ycenter;
gimp_pixel_rgn_init (&src_rgn, drawable,
x1, y1, x2-x1, y2-y1, FALSE, FALSE);
gimp_pixel_rgn_init (&dest_rgn, drawable,
x1, y1, x2-x1, y2-y1, TRUE, TRUE);
}
1999-09-03 23:14:44 +00:00
/* Initialize progress */
progress = 0;
1999-09-03 23:14:44 +00:00
max_progress = (x2 - x1) * (y2 - y1);
if (preview_mode)
1999-09-03 23:14:44 +00:00
{
src_row = g_malloc (y2 * preview->rowstride);
memcpy (src_row, preview->cache, y2 * preview->rowstride);
dest_row = g_malloc (preview->rowstride);
for (row = 0, y = 0; row < y2; row++, y++)
1999-09-03 23:14:44 +00:00
{
src = src_row;
1999-09-03 23:14:44 +00:00
dest = dest_row;
for (col = 0, x = 0; col < x2; col++, x++)
1999-09-03 23:14:44 +00:00
{
u = (gdouble) (x - xc) / (pvals.radius * preview->scale_x);
v = (gdouble) (y - yc) / (pvals.radius * preview->scale_y);
l = sqrt (u * u + v * v);
1999-09-03 23:14:44 +00:00
/* This algorithm is still under construction. */
c = (atan2 (u, v) / (2 * G_PI) + .51) * pvals.nspoke;
i = (gint) floor (c);
1999-09-03 23:14:44 +00:00
c -= i;
i %= pvals.nspoke;
w1 = spoke[i] * (1 - c) + spoke[(i + 1) % pvals.nspoke] * c;
w1 = w1 * w1;
w = 1.0 / (l + 0.001) * 0.9;
1999-09-03 23:14:44 +00:00
nova_alpha = CLAMP (w, 0.0, 1.0);
/* blend two neighbored spokecolors */
color = spokecolor[i];
gimp_rgb_set_alpha (&color, 1.0);
gimp_rgb_set_alpha (spokecolor + ((i + 1) % pvals.nspoke), c);
gimp_rgb_composite (&color,
spokecolor + (i + 1) % pvals.nspoke,
GIMP_RGB_COMPOSITE_NORMAL);
1999-09-03 23:14:44 +00:00
if (w > 1.0)
{
gimp_rgb_multiply (&color, w);
gimp_rgb_clamp (&color);
}
else
{
gimp_rgba_set_uchar (&src_color,
src[0], src[1], src[2], 1.0);
gimp_rgb_set_alpha (&color, nova_alpha);
gimp_rgb_composite (&color, &src_color,
GIMP_RGB_COMPOSITE_BEHIND);
}
/* c = CLAMP (w1 * w, 0.0, 1.0); */
/* gimp_rgb_add (&color, c); */
gimp_rgb_get_uchar (&color,
dest, dest + 1, dest + 2);
src += bpp;
dest += bpp;
1999-09-03 23:14:44 +00:00
}
src_row += preview->rowstride;
gimp_fixme_preview_do_row (preview, row, y2, dest_row);
1999-09-03 23:14:44 +00:00
}
gtk_widget_queue_draw (preview->widget);
}
else
{ /* normal mode */
#ifdef EEEEK
for (pr = gimp_pixel_rgns_register (2, &src_rgn, &dest_rgn);
pr != NULL; pr = gimp_pixel_rgns_process (pr))
{
src_row = src_rgn.data;
dest_row = dest_rgn.data;
for (row = 0, y = src_rgn.y; row < src_rgn.h; row++, y++)
{
src = src_row;
dest = dest_row;
for (col = 0, x = src_rgn.x; col < src_rgn.w; col++, x++)
{
u = (gdouble) (x-xc) / pvals.radius;
v = (gdouble) (y-yc) / pvals.radius;
l = sqrt(u*u + v*v);
/* This algorithm is still under construction. */
c = (atan2 (u, v) / (2 * G_PI) + .51) * pvals.nspoke;
i = (gint) floor (c);
c -= i;
i %= pvals.nspoke;
w1 = spoke[i] * (1 - c) + spoke[(i + 1) % pvals.nspoke] * c;
w1 = w1 * w1;
w = 1/(l+0.001)*0.9;
nova_alpha = CLAMP (w, 0.0, 1.0);
switch (bpp)
{
case 1:
gimp_rgba_set_uchar (&src_color,
src[0], src[0], src[0], 1.0);
break;
case 2:
gimp_rgba_set_uchar (&src_color,
src[0], src[0], src[0], src[1]);
break;
case 3:
gimp_rgba_set_uchar (&src_color,
src[0], src[1], src[2], 1.0);
break;
case 4:
gimp_rgba_set_uchar (&src_color,
src[0], src[1], src[2], src[3]);
break;
}
if (has_alpha)
{
src_alpha = (gdouble) src[alpha] / 255.0;
new_alpha = src_alpha + (1.0 - src_alpha) * nova_alpha;
if (new_alpha != 0.0)
ratio = nova_alpha / new_alpha;
else
ratio = 0.0;
}
else
ratio = nova_alpha;
compl_ratio = 1.0 - ratio;
for (j = 0; j < alpha; j++)
{
spokecol = (gdouble)spokecolor[3*i+j]*(1.0-c) +
(gdouble)spokecolor[3*((i + 1) % pvals.nspoke)+j]*c;
if (w > 1.0)
color[j] = CLAMP (spokecol * w, 0, 255);
else
color[j] = src[j] * compl_ratio + spokecol * ratio;
c = CLAMP (w1 * w, 0, 1);
color[j] = color[j] + 255 * c;
dest[j]= CLAMP (color[j], 0, 255);
}
if (has_alpha)
dest[alpha] = new_alpha * 255.0;
src += src_rgn.bpp;
dest += dest_rgn.bpp;
}
src_row += src_rgn.rowstride;
dest_row += dest_rgn.rowstride;
}
/* Update progress */
progress += src_rgn.w * src_rgn.h;
gimp_progress_update ((gdouble) progress / (gdouble) max_progress);
}
gimp_drawable_flush (drawable);
gimp_drawable_merge_shadow (drawable->drawable_id, TRUE);
gimp_drawable_update (drawable->drawable_id,
x1, y1, (x2 - x1), (y2 - y1));
#else
gimp_message ("Sorry, the SuperNova effect\n"
"is broken at the moment and\n"
"has been temporarily disabled.");
#endif
1999-09-03 23:14:44 +00:00
}
g_free (spoke);
g_free (spokecolor);
2000-01-09 15:51:46 +00:00
}