gimp/app/core/gimpbrushgenerated.c

587 lines
14 KiB
C
Raw Normal View History

/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimp_brush_generated module Copyright 1998 Jay Cox <jaycox@earthlink.net>
*
* 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
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <errno.h>
#include <stdio.h>
#include <string.h>
1999-10-27 02:27:27 +08:00
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
an evil temp_hack which lets GimpContext managing the active display 2001-08-14 Michael Natterer <mitch@gimp.org> * app/gdisplay.h: an evil temp_hack which lets GimpContext managing the active display withoug including "gdisplay.h". Will go away as soon ad context properties are registered dynamically. * app/module_db.c: cleaned up the object code in preparation of moving it to core/. * app/path.c: connect to GimpImage's * app/core/gimpobject.[ch]: derive it from GObject, not from GtkObject any more (yeah :-) * app/core/*.c: #include <glib-object.h> instead of <gtk/gtk.h>, removed some remaining GtkObject-isms. (left in a few #include <gtk/gtk.h> where bigger changes are needed to get rid of the UI dependency). * app/core/core-types.h: #include <gdk-pixbuf/gdk-pixbuf.h> here temporarily. * app/core/gimp.c (gimp_create_display): unref the image after creating it's first display. * app/core/gimpbrush.[ch]: disabled the parts of the code which depend on GimpPaintTool. * app/core/gimpbrushgenerated.c * app/core/gimpbrushpipe.c: changed accordingly. * app/core/gimpcontext.[ch]: evil hack (see above) to manage the active display without including "gdisplay.h" * app/core/gimpimage-mask.[ch]: pass a context to gimage_mask_stroke() and get the current tool's PDB string from there. * app/core/gimpedit.c: changed accordingly. * app/core/gimpimage.c: use gimp_image_update() instead of gdisplays_update_full(). * app/gui/color-area.c * app/gui/colormap-dialog.c * app/gui/dialogs-constructors.c * app/gui/edit-commands.c * app/gui/image-commands.c * app/gui/toolbox.c: changed accordingly (don't use Gtk methods on GObjects). * app/gui/menus.c: fix some const warnings by explicit casting. * app/tools/*.[ch]: ported all tools to GObject, some minor cleanup while i was on it. * app/widgets/gimpdialogfactory.[ch]: ported to GObject. * app/widgets/gimplayerlistview.h: added FOO_GET_CLASS() macro. * tools/pdbgen/app.pl: added a "widgets_eek" hack like "tools_eek" which inserts #include "widgets/widgets-types.h" before ordinary includes. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/edit.pdb * app/pdb/brush_select_cmds.c * app/pdb/edit_cmds.c: changed according to the stuff above.
2001-08-14 22:53:55 +08:00
#include <glib-object.h>
#include "libgimpmath/gimpmath.h"
#include "core-types.h"
new directory app/base/ 2001-05-15 Michael Natterer <mitch@gimp.org> * configure.in: new directory app/base/ * app/Makefile.am * app/boundary.[ch] * app/brush_scale.[ch] * app/gimpchecks.h * app/gimplut.[ch] * app/pixel_processor.[ch] * app/pixel_region.[ch] * app/pixel_surround.[ch] * app/temp_buf.[ch] * app/tile.[ch] * app/tile_cache.[ch] * app/tile_manager.[ch] * app/tile_manager_pvt.h * app/tile_pvt.h * app/tile_swap.[ch]: moved to base/ * app/base/Makefile.am * app/base/base-types.h * app/base/*: new directory for the sub-object pixel maniplation and storage stuff. Does not include Gtk+ or anything outside base/. Did some cleanup in all files. * app/appenums.h * app/apptypes.h * app/core/gimpimage.h: removed types which are now in base/base-types.h. * app/base/base-config.[ch] * app/gimprc.[ch]: put the config variables for base/ to their own file so base/ doesn not have to include gimprc.h (does not yet work, i.e. the variables are un-configurable right now) * app/main.c: set a log handler for "Gimp-Base". * app/paint-funcs/Makefile.am * app/paint-funcs/paint-funcs.[ch]: removed the color hash which maps RGB to color indices because it's a totally standalone system which has nothing to do with the paint-funcs and introduced a GimpImage dependency. paint-funcs/ should be considered on the same sub-object (glib-only) level as base/, only in a different directory. * app/core/Makefile.am * app/core/gimpimage-colorhash.[ch]: put the color hash here. * app/gimage.c: don't invalidate the color hash here... * app/core/gimpimage.c: ... but in the colormap_changed() default inplementation. Initialize the hash in class_init(). * tools/pdbgen/Makefile.am: scan app/base/base-types.h for enums. * tools/pdbgen/enums.pl: regenerated. * app/[lots] * app/core/[of] * app/gui/[files] * app/pdb/[all] * app/tools/[over] * app/widgets/[the] * tools/pdbgen/pdb/[place]: changed #includes accordingly. And use base_config->value instead of the stuff from gimprc.h.
2001-05-15 19:25:25 +08:00
#include "base/temp-buf.h"
#include "gimpbrushgenerated.h"
#include "gimp-intl.h"
app/Makefile.am app/channel_pvt.h app/drawable_pvt.h app/gdisplayF.h 2000-12-29 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/channel_pvt.h * app/drawable_pvt.h * app/gdisplayF.h * app/gimpdrawableP.h * app/gimpimageP.h * app/layer_pvt.h * app/toolsF.h: removed these files. * app/apptypes.h * tools/pdbgen/enums.pl: added tons of opaque typedefs and enums. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/display.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/help.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/tools.pdb * app/*: chainsaw #include cleanup: - Never (never!!) include stuff in header files except where we need access to structures' contents (like derived objects). - Added prototypes and proper formating in many files. - The #include order in *all* *.c files is as follows: #include "config.h" #include <system stuff> #include <gtk/gtk.h> #include "apptypes.h" #include "gimp stuff" #include "libgimp stuff" #include "libgimp/gimpintl.h" By following this scheme we can easily see a file's dependencies from it's #include's and can grep for the inclusion to find out where a file is used. * tools/pdbgen/app.pl: changed to follow the include scheme above. * libgimp/Makefile.am * libgimp/gimpuitypes.h: new file, included from libgimp/gimpui.h and from app/apptypes.h. * libgimp/gimpcolorbutton.[ch] * libgimp/gimpdialog.[ch] * libgimp/gimphelpui.[ch] * libgimp/gimpparasite.[ch] * libgimp/gimppatheditor.[ch] * libgimp/gimpprotocol.c * libgimp/gimpquerybox.[ch] * libgimp/gimpsizeentry.[ch] * libgimp/gimptypes.h * libgimp/gimpui.h * libgimp/gimpunit.h * libgimp/gimpunitmenu.[ch] * libgimp/gimpwidgets.[ch]: changed accordingly. * plug-ins/FractalExplorer/Dialogs.c * plug-ins/gdyntext/message_window.c * plug-ins/imagemap/imap_default_dialog.c * plug-ins/imagemap/imap_file.c: these files used to include "libgimp/gimpui.h" without including "libgimp/gimp.h". This is no longer possible because the libgimpui headers don't inlcude "libgimp/gimpunit.h" any more.
2000-12-29 23:22:01 +08:00
#define OVERSAMPLING 5
/* local function prototypes */
static void gimp_brush_generated_class_init (GimpBrushGeneratedClass *klass);
static void gimp_brush_generated_init (GimpBrushGenerated *brush);
static gboolean gimp_brush_generated_save (GimpData *data,
GError **error);
static void gimp_brush_generated_dirty (GimpData *data);
static gchar * gimp_brush_generated_get_extension (GimpData *data);
static GimpData * gimp_brush_generated_duplicate (GimpData *data,
gboolean stingy_memory_use);
static GimpBrushClass *parent_class = NULL;
GType
1999-10-27 02:27:27 +08:00
gimp_brush_generated_get_type (void)
{
static GType brush_type = 0;
1999-10-27 02:27:27 +08:00
if (! brush_type)
1999-10-27 02:27:27 +08:00
{
static const GTypeInfo brush_info =
1999-10-27 02:27:27 +08:00
{
sizeof (GimpBrushGeneratedClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_brush_generated_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
1999-10-27 02:27:27 +08:00
sizeof (GimpBrushGenerated),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_brush_generated_init,
1999-10-27 02:27:27 +08:00
};
brush_type = g_type_register_static (GIMP_TYPE_BRUSH,
"GimpBrushGenerated",
&brush_info, 0);
1999-10-27 02:27:27 +08:00
}
return brush_type;
}
static void
gimp_brush_generated_class_init (GimpBrushGeneratedClass *klass)
{
GimpDataClass *data_class;
data_class = GIMP_DATA_CLASS (klass);
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning) 2001-07-24 Michael Natterer <mitch@gimp.org> Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning) * configure.in: require glib/gtk+ >= 1.3.7, commented out the gtkxmhtml stuff. From now on, you will need glib, pango, atk and gtk+ HEAD from CVS to hack or use GIMP HEAD. Beware, it crashes randomly :) * app/core/Makefile.am * app/core/gimpmarshal.list: new file plus rules to generate gimpmarshal.[ch] from it. * app/core/* * app/tools/* * app/widgets/* * libgimpwidgets/*: started to use the glib object system. All core/ objects are still gtk objects however. All signals are created using g_signal_new(). There are many gtk+ artefacts left. Finally, we will _not_ use the gtk_signal_foo() wrappers and friends any more. * app/colormaps.c * app/devices.[ch] * app/disp_callbacks.c * app/errorconsole.c * app/file-save.[ch] * app/interface.c * app/module_db.c * app/nav_window.c * app/ops_buttons.c * app/scroll.c * app/user_install.c * app/gui/about-dialog.c * app/gui/brush-editor.c * app/gui/brushes-commands.c * app/gui/color-notebook.c * app/gui/colormap-dialog.c * app/gui/dialogs-commands.c * app/gui/dialogs-constructors.c * app/gui/file-commands.c * app/gui/file-dialog-utils.c * app/gui/file-new-dialog.c * app/gui/file-open-dialog.[ch] * app/gui/file-save-dialog.c * app/gui/gradient-editor.c * app/gui/gradients-commands.c * app/gui/image-commands.c * app/gui/info-dialog.[ch] * app/gui/layer-select.c * app/gui/layers-commands.c * app/gui/menus.c * app/gui/offset-dialog.c * app/gui/palette-editor.c * app/gui/palettes-commands.c * app/gui/patterns-commands.c * app/gui/preferences-dialog.c * app/gui/resize-dialog.[ch] * app/gui/splash.c * app/gui/tips-dialog.c * app/gui/tool-options-dialog.c * app/gui/toolbox.c * app/gui/tools-commands.c * libgimp/gimpbrushmenu.c * libgimp/gimpmenu.c * libgimp/gimppatternmenu.c * libgimp/gimpui.c * libgimpbase/gimpenv.c: tons and tons of changes like "const gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete and currently disables), lots of s/gtk_signal/g_signal/, removal/replacement of deprecated stuff, s/GtkSignalFunc/GCallback/ and lots of small changes and fixes while I was on it, zillions of warnings left... * modules/Makefile.am: disabled the water color selector temporarily (XInput issues). * plug-ins/Makefile.am * plug-ins/common/.cvsignore * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl: simply excluded all plug-ins which did not build (including Script-Fu). They are trivial to fix.
2001-07-25 05:27:11 +08:00
parent_class = g_type_class_peek_parent (klass);
gimprc.in user_install user_install.bat app/gimprc.[ch] removed the 2001-02-13 Michael Natterer <mitch@gimp.org> * gimprc.in * user_install * user_install.bat * app/gimprc.[ch] * app/preferences_dialog.c: removed the "brush_vbr_path" variable, because all data types will be editable and saveable soon. * app/Makefile.am * app/apptypes.h * app/gimpdatafactory.[ch]: new object which holds a data list and knows how to create, edit, duplicate etc. the items in it. Will completely replace the brushes.[ch], patterns.[ch], ... files soon. * po/POTFILES.in * app/gimpdatacontainerview.[ch]: removed. * app/gimpdatafactoryview.[ch]: added. A view on the GimpDataFactory with a GUI for creating, editing, deleting etc. items (mostly unimplemented). * app/context_manager.[ch]: replaced the global data lists by global data factories. * app/brush_select.c * app/brushes.[ch] * app/commands.c * app/convert.c * app/devices.c * app/gimpbrush.[ch] * app/gimpbrushgenerated.c * app/gimpcontext.c * app/gimpdata.[ch] * app/gimpdatalist.[ch] * app/gimpdnd.c * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch] * app/gradient_editor.c * app/gradient_select.c * app/gradients.[ch] * app/indicator_area.c * app/palette.c * app/palette_import.c * app/palette_select.c * app/palettes.[ch] * app/pattern_select.c * app/patterns.[ch] * app/pdb/brush_select_cmds.c * app/pdb/brushes_cmds.c * app/pdb/convert_cmds.c * app/pdb/gradient_select_cmds.c * app/pdb/gradients_cmds.c * app/pdb/pattern_select_cmds.c * app/pdb/patterns_cmds.c * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb: changed accordingly.
2001-02-14 03:53:07 +08:00
data_class->save = gimp_brush_generated_save;
data_class->dirty = gimp_brush_generated_dirty;
data_class->get_extension = gimp_brush_generated_get_extension;
data_class->duplicate = gimp_brush_generated_duplicate;
}
static void
gimp_brush_generated_init (GimpBrushGenerated *brush)
{
brush->radius = 5.0;
brush->hardness = 0.0;
brush->angle = 0.0;
brush->aspect_ratio = 1.0;
brush->freeze = 0;
}
static gboolean
gimp_brush_generated_save (GimpData *data,
GError **error)
{
GimpBrushGenerated *brush;
FILE *fp;
gchar buf[G_ASCII_DTOSTR_BUF_SIZE];
brush = GIMP_BRUSH_GENERATED (data);
/* we are (finaly) ready to try to save the generated brush file */
if ((fp = fopen (data->filename, "wb")) == NULL)
1999-10-27 02:27:27 +08:00
{
g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_OPEN,
_("Could not open '%s' for writing: %s"),
data->filename, g_strerror (errno));
return FALSE;
1999-10-27 02:27:27 +08:00
}
/* write magic header */
fprintf (fp, "GIMP-VBR\n");
/* write version */
fprintf (fp, "1.0\n");
/* write name */
fprintf (fp, "%.255s\n", GIMP_OBJECT (brush)->name);
1999-10-27 02:27:27 +08:00
/* write brush spacing */
fprintf (fp, "%s\n",
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f",
GIMP_BRUSH (brush)->spacing));
1999-10-27 02:27:27 +08:00
/* write brush radius */
fprintf (fp, "%s\n",
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f",
brush->radius));
1999-10-27 02:27:27 +08:00
/* write brush hardness */
fprintf (fp, "%s\n",
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f",
brush->hardness));
1999-10-27 02:27:27 +08:00
/* write brush aspect_ratio */
fprintf (fp, "%s\n",
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f",
brush->aspect_ratio));
1999-10-27 02:27:27 +08:00
/* write brush angle */
fprintf (fp, "%s\n",
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f",
brush->angle));
1999-10-27 02:27:27 +08:00
fclose (fp);
return TRUE;
}
gimprc.in user_install user_install.bat app/gimprc.[ch] removed the 2001-02-13 Michael Natterer <mitch@gimp.org> * gimprc.in * user_install * user_install.bat * app/gimprc.[ch] * app/preferences_dialog.c: removed the "brush_vbr_path" variable, because all data types will be editable and saveable soon. * app/Makefile.am * app/apptypes.h * app/gimpdatafactory.[ch]: new object which holds a data list and knows how to create, edit, duplicate etc. the items in it. Will completely replace the brushes.[ch], patterns.[ch], ... files soon. * po/POTFILES.in * app/gimpdatacontainerview.[ch]: removed. * app/gimpdatafactoryview.[ch]: added. A view on the GimpDataFactory with a GUI for creating, editing, deleting etc. items (mostly unimplemented). * app/context_manager.[ch]: replaced the global data lists by global data factories. * app/brush_select.c * app/brushes.[ch] * app/commands.c * app/convert.c * app/devices.c * app/gimpbrush.[ch] * app/gimpbrushgenerated.c * app/gimpcontext.c * app/gimpdata.[ch] * app/gimpdatalist.[ch] * app/gimpdnd.c * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch] * app/gradient_editor.c * app/gradient_select.c * app/gradients.[ch] * app/indicator_area.c * app/palette.c * app/palette_import.c * app/palette_select.c * app/palettes.[ch] * app/pattern_select.c * app/patterns.[ch] * app/pdb/brush_select_cmds.c * app/pdb/brushes_cmds.c * app/pdb/convert_cmds.c * app/pdb/gradient_select_cmds.c * app/pdb/gradients_cmds.c * app/pdb/pattern_select_cmds.c * app/pdb/patterns_cmds.c * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb: changed accordingly.
2001-02-14 03:53:07 +08:00
static gchar *
gimp_brush_generated_get_extension (GimpData *data)
{
return GIMP_BRUSH_GENERATED_FILE_EXTENSION;
}
static GimpData *
gimp_brush_generated_duplicate (GimpData *data,
gboolean stingy_memory_use)
{
GimpBrushGenerated *brush;
brush = GIMP_BRUSH_GENERATED (data);
return gimp_brush_generated_new (brush->radius,
brush->hardness,
brush->angle,
brush->aspect_ratio,
stingy_memory_use);
}
static gdouble
1999-10-27 02:27:27 +08:00
gauss (gdouble f)
{
1999-10-27 02:27:27 +08:00
/* this aint' a real gauss function */
if (f < -0.5)
{
f = -1.0 - f;
return (2.0 * f*f);
}
if (f < 0.5)
return (1.0 - 2.0 * f*f);
f = 1.0 - f;
return (2.0 * f*f);
}
static void
gimp_brush_generated_dirty (GimpData *data)
{
GimpBrushGenerated *brush;
GimpBrush *gbrush = NULL;
gint x, y;
guchar *centerp;
gdouble d;
gdouble exponent;
guchar a;
gint length;
gint width, height;
guchar *lookup;
gdouble sum;
gdouble c, s;
gdouble short_radius;
gdouble buffer[OVERSAMPLING];
brush = GIMP_BRUSH_GENERATED (data);
if (brush->freeze) /* if we are frozen defer rerendering till later */
return;
1999-10-27 02:27:27 +08:00
gbrush = GIMP_BRUSH (brush);
if (gbrush->mask)
temp_buf_free (gbrush->mask);
s = sin (gimp_deg_to_rad (brush->angle));
c = cos (gimp_deg_to_rad (brush->angle));
short_radius = brush->radius / brush->aspect_ratio;
gbrush->x_axis.x = c * brush->radius;
gbrush->x_axis.y = -1.0 * s * brush->radius;
gbrush->y_axis.x = s * short_radius;
gbrush->y_axis.y = c * short_radius;
width = ceil (sqrt (gbrush->x_axis.x * gbrush->x_axis.x +
gbrush->y_axis.x * gbrush->y_axis.x));
height = ceil (sqrt (gbrush->x_axis.y * gbrush->x_axis.y +
gbrush->y_axis.y * gbrush->y_axis.y));
gbrush->mask = temp_buf_new (width * 2 + 1,
height * 2 + 1,
1999-10-27 02:27:27 +08:00
1, width, height, 0);
centerp = temp_buf_data (gbrush->mask) + height * gbrush->mask->width + width;
/* set up lookup table */
length = OVERSAMPLING * ceil (1 + sqrt (2 *
ceil (brush->radius + 1.0) *
ceil (brush->radius + 1.0)));
if ((1.0 - brush->hardness) < 0.000001)
exponent = 1000000.0;
else
exponent = 1.0 / (1.0 - brush->hardness);
1999-10-27 02:27:27 +08:00
lookup = g_malloc (length);
sum = 0.0;
for (x = 0; x < OVERSAMPLING; x++)
1999-10-27 02:27:27 +08:00
{
d = fabs ((x + 0.5) / OVERSAMPLING - 0.5);
1999-10-27 02:27:27 +08:00
if (d > brush->radius)
buffer[x] = 0.0;
else
buffer[x] = gauss (pow (d / brush->radius, exponent));
sum += buffer[x];
}
for (x = 0; d < brush->radius || sum > 0.00001; d += 1.0 / OVERSAMPLING)
{
sum -= buffer[x % OVERSAMPLING];
if (d > brush->radius)
buffer[x % OVERSAMPLING] = 0.0;
1999-10-27 02:27:27 +08:00
else
buffer[x % OVERSAMPLING] = gauss (pow (d / brush->radius, exponent));
sum += buffer[x % OVERSAMPLING];
lookup[x++] = RINT (sum * (255.0 / OVERSAMPLING));
1999-10-27 02:27:27 +08:00
}
while (x < length)
1999-10-27 02:27:27 +08:00
{
lookup[x++] = 0;
}
1999-10-27 02:27:27 +08:00
/* compute one half and mirror it */
for (y = 0; y <= height; y++)
{
1999-10-27 02:27:27 +08:00
for (x = -width; x <= width; x++)
{
gdouble tx, ty;
1999-10-27 02:27:27 +08:00
tx = c*x - s*y;
ty = c*y + s*x;
ty *= brush->aspect_ratio;
d = sqrt (tx*tx + ty*ty);
if (d < brush->radius + 1)
a = lookup[(gint) RINT (d * OVERSAMPLING)];
1999-10-27 02:27:27 +08:00
else
a = 0;
centerp[ y * gbrush->mask->width + x] = a;
centerp[-1 * y * gbrush->mask->width - x] = a;
1999-10-27 02:27:27 +08:00
}
}
g_free (lookup);
if (GIMP_DATA_CLASS (parent_class)->dirty)
GIMP_DATA_CLASS (parent_class)->dirty (data);
}
added a note about apptype.h and about not including headers in headers. 2001-02-14 Michael Natterer <mitch@gimp.org> * HACKING: added a note about apptype.h and about not including headers in headers. * app/apptypes.h: added GimpTool and BitmapCursor. * app/cursorutil.h * app/devices.h * app/draw_core.h * app/tools/color_picker.h * app/tools/tool.h * app/tools/tool_options.h * app/gimpcontext.h: removed includes of "tools/tool.h" * app/gimprc.[ch]: indentadion cleanup, added "module_db_load_inhibit". * app/module_db.c: removed the above variable here. * app/gimpdata.[ch]: added a vitrual "duplicate" method. * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushpipe.[ch] * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch]: all "load", "new" and "get_standard" functions return a GimpData pointer now. * app/gimpdatafactory.[ch]: made some stuff const. * app/gimpdatafactoryview.c: activate the "duplicate" button and set the initial button sensitivity correctly. * app/brush_select.c * app/gradient_select.c * app/pattern_select.c: use the new GimpDataFactoryView. * libgimp/Makefile.am: grouped the file to sort out what _may_ go to subdirs or separate libs. * libgimp/gimpenv.[ch]: added many "const". * app/app_procs.c * app/brush_edit.c * app/gimpcontext.c * app/gimpdnd.c * app/gradient_editor.c * app/palette.c * app/palette_import.c * app/user_install.c: many related changes. * libgimpmath/gimpmathtypes.h * libgimpmath/gimpvector.[ch]: minor cleanups. * plug-ins/script-fu/script-fu.c: gimp_data_directory() is const now.
2001-02-14 22:57:14 +08:00
GimpData *
gimp_brush_generated_new (gfloat radius,
gfloat hardness,
gfloat angle,
gfloat aspect_ratio,
gboolean stingy_memory_use)
{
GimpBrushGenerated *brush;
/* set up normal brush data */
brush = g_object_new (GIMP_TYPE_BRUSH_GENERATED, NULL);
gimp_object_set_name (GIMP_OBJECT (brush), "Untitled");
GIMP_BRUSH (brush)->spacing = 20;
/* set up gimp_brush_generated data */
brush->radius = radius;
brush->hardness = hardness;
brush->angle = angle;
brush->aspect_ratio = aspect_ratio;
/* render brush mask */
gimp_data_dirty (GIMP_DATA (brush));
if (stingy_memory_use)
temp_buf_swap (GIMP_BRUSH (brush)->mask);
added a note about apptype.h and about not including headers in headers. 2001-02-14 Michael Natterer <mitch@gimp.org> * HACKING: added a note about apptype.h and about not including headers in headers. * app/apptypes.h: added GimpTool and BitmapCursor. * app/cursorutil.h * app/devices.h * app/draw_core.h * app/tools/color_picker.h * app/tools/tool.h * app/tools/tool_options.h * app/gimpcontext.h: removed includes of "tools/tool.h" * app/gimprc.[ch]: indentadion cleanup, added "module_db_load_inhibit". * app/module_db.c: removed the above variable here. * app/gimpdata.[ch]: added a vitrual "duplicate" method. * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushpipe.[ch] * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch]: all "load", "new" and "get_standard" functions return a GimpData pointer now. * app/gimpdatafactory.[ch]: made some stuff const. * app/gimpdatafactoryview.c: activate the "duplicate" button and set the initial button sensitivity correctly. * app/brush_select.c * app/gradient_select.c * app/pattern_select.c: use the new GimpDataFactoryView. * libgimp/Makefile.am: grouped the file to sort out what _may_ go to subdirs or separate libs. * libgimp/gimpenv.[ch]: added many "const". * app/app_procs.c * app/brush_edit.c * app/gimpcontext.c * app/gimpdnd.c * app/gradient_editor.c * app/palette.c * app/palette_import.c * app/user_install.c: many related changes. * libgimpmath/gimpmathtypes.h * libgimpmath/gimpvector.[ch]: minor cleanups. * plug-ins/script-fu/script-fu.c: gimp_data_directory() is const now.
2001-02-14 22:57:14 +08:00
return GIMP_DATA (brush);
}
added a note about apptype.h and about not including headers in headers. 2001-02-14 Michael Natterer <mitch@gimp.org> * HACKING: added a note about apptype.h and about not including headers in headers. * app/apptypes.h: added GimpTool and BitmapCursor. * app/cursorutil.h * app/devices.h * app/draw_core.h * app/tools/color_picker.h * app/tools/tool.h * app/tools/tool_options.h * app/gimpcontext.h: removed includes of "tools/tool.h" * app/gimprc.[ch]: indentadion cleanup, added "module_db_load_inhibit". * app/module_db.c: removed the above variable here. * app/gimpdata.[ch]: added a vitrual "duplicate" method. * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushpipe.[ch] * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch]: all "load", "new" and "get_standard" functions return a GimpData pointer now. * app/gimpdatafactory.[ch]: made some stuff const. * app/gimpdatafactoryview.c: activate the "duplicate" button and set the initial button sensitivity correctly. * app/brush_select.c * app/gradient_select.c * app/pattern_select.c: use the new GimpDataFactoryView. * libgimp/Makefile.am: grouped the file to sort out what _may_ go to subdirs or separate libs. * libgimp/gimpenv.[ch]: added many "const". * app/app_procs.c * app/brush_edit.c * app/gimpcontext.c * app/gimpdnd.c * app/gradient_editor.c * app/palette.c * app/palette_import.c * app/user_install.c: many related changes. * libgimpmath/gimpmathtypes.h * libgimpmath/gimpvector.[ch]: minor cleanups. * plug-ins/script-fu/script-fu.c: gimp_data_directory() is const now.
2001-02-14 22:57:14 +08:00
GimpData *
gimp_brush_generated_load (const gchar *filename,
gboolean stingy_memory_use,
GError **error)
{
GimpBrushGenerated *brush;
added a note about apptype.h and about not including headers in headers. 2001-02-14 Michael Natterer <mitch@gimp.org> * HACKING: added a note about apptype.h and about not including headers in headers. * app/apptypes.h: added GimpTool and BitmapCursor. * app/cursorutil.h * app/devices.h * app/draw_core.h * app/tools/color_picker.h * app/tools/tool.h * app/tools/tool_options.h * app/gimpcontext.h: removed includes of "tools/tool.h" * app/gimprc.[ch]: indentadion cleanup, added "module_db_load_inhibit". * app/module_db.c: removed the above variable here. * app/gimpdata.[ch]: added a vitrual "duplicate" method. * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushpipe.[ch] * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch]: all "load", "new" and "get_standard" functions return a GimpData pointer now. * app/gimpdatafactory.[ch]: made some stuff const. * app/gimpdatafactoryview.c: activate the "duplicate" button and set the initial button sensitivity correctly. * app/brush_select.c * app/gradient_select.c * app/pattern_select.c: use the new GimpDataFactoryView. * libgimp/Makefile.am: grouped the file to sort out what _may_ go to subdirs or separate libs. * libgimp/gimpenv.[ch]: added many "const". * app/app_procs.c * app/brush_edit.c * app/gimpcontext.c * app/gimpdnd.c * app/gradient_editor.c * app/palette.c * app/palette_import.c * app/user_install.c: many related changes. * libgimpmath/gimpmathtypes.h * libgimpmath/gimpvector.[ch]: minor cleanups. * plug-ins/script-fu/script-fu.c: gimp_data_directory() is const now.
2001-02-14 22:57:14 +08:00
FILE *fp;
gchar string[256];
g_return_val_if_fail (filename != NULL, NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
if ((fp = fopen (filename, "rb")) == NULL)
{
g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_OPEN,
_("Could not open '%s' for reading: %s"),
filename, g_strerror (errno));
return NULL;
}
/* make sure the file we are reading is the right type */
fgets (string, 255, fp);
if (strncmp (string, "GIMP-VBR", 8) != 0)
{
g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
_("Fatal Parse Error: '%s' is not a GIMP Brush file"),
filename);
return NULL;
}
added a note about apptype.h and about not including headers in headers. 2001-02-14 Michael Natterer <mitch@gimp.org> * HACKING: added a note about apptype.h and about not including headers in headers. * app/apptypes.h: added GimpTool and BitmapCursor. * app/cursorutil.h * app/devices.h * app/draw_core.h * app/tools/color_picker.h * app/tools/tool.h * app/tools/tool_options.h * app/gimpcontext.h: removed includes of "tools/tool.h" * app/gimprc.[ch]: indentadion cleanup, added "module_db_load_inhibit". * app/module_db.c: removed the above variable here. * app/gimpdata.[ch]: added a vitrual "duplicate" method. * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushpipe.[ch] * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch]: all "load", "new" and "get_standard" functions return a GimpData pointer now. * app/gimpdatafactory.[ch]: made some stuff const. * app/gimpdatafactoryview.c: activate the "duplicate" button and set the initial button sensitivity correctly. * app/brush_select.c * app/gradient_select.c * app/pattern_select.c: use the new GimpDataFactoryView. * libgimp/Makefile.am: grouped the file to sort out what _may_ go to subdirs or separate libs. * libgimp/gimpenv.[ch]: added many "const". * app/app_procs.c * app/brush_edit.c * app/gimpcontext.c * app/gimpdnd.c * app/gradient_editor.c * app/palette.c * app/palette_import.c * app/user_install.c: many related changes. * libgimpmath/gimpmathtypes.h * libgimpmath/gimpvector.[ch]: minor cleanups. * plug-ins/script-fu/script-fu.c: gimp_data_directory() is const now.
2001-02-14 22:57:14 +08:00
/* make sure we are reading a compatible version */
fgets (string, 255, fp);
if (strncmp (string, "1.0", 3))
{
g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
_("Fatal Parse Error: '%s': unknown GIMP Brush version"),
filename);
return NULL;
}
/* create new brush */
brush = g_object_new (GIMP_TYPE_BRUSH_GENERATED, NULL);
gimp_data_set_filename (GIMP_DATA (brush), filename);
gimp_brush_generated_freeze (brush);
/* read name */
fgets (string, 255, fp);
if (string[strlen (string) - 1] == '\n')
string[strlen (string) - 1] = 0;
gimp_object_set_name (GIMP_OBJECT (brush), string);
/* read brush spacing */
fgets (string, 255, fp);
GIMP_BRUSH (brush)->spacing = g_ascii_strtod (string, NULL);
/* read brush radius */
fgets (string, 255, fp);
gimp_brush_generated_set_radius (brush, g_ascii_strtod (string, NULL));
/* read brush hardness */
fgets (string, 255, fp);
gimp_brush_generated_set_hardness (brush, g_ascii_strtod (string, NULL));
/* read brush aspect_ratio */
fgets (string, 255, fp);
gimp_brush_generated_set_aspect_ratio (brush, g_ascii_strtod (string, NULL));
/* read brush angle */
fgets (string, 255, fp);
gimp_brush_generated_set_angle (brush, g_ascii_strtod (string, NULL));
fclose (fp);
gimp_brush_generated_thaw (brush);
if (stingy_memory_use)
temp_buf_swap (GIMP_BRUSH (brush)->mask);
GIMP_DATA (brush)->dirty = FALSE;
added a note about apptype.h and about not including headers in headers. 2001-02-14 Michael Natterer <mitch@gimp.org> * HACKING: added a note about apptype.h and about not including headers in headers. * app/apptypes.h: added GimpTool and BitmapCursor. * app/cursorutil.h * app/devices.h * app/draw_core.h * app/tools/color_picker.h * app/tools/tool.h * app/tools/tool_options.h * app/gimpcontext.h: removed includes of "tools/tool.h" * app/gimprc.[ch]: indentadion cleanup, added "module_db_load_inhibit". * app/module_db.c: removed the above variable here. * app/gimpdata.[ch]: added a vitrual "duplicate" method. * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushpipe.[ch] * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch]: all "load", "new" and "get_standard" functions return a GimpData pointer now. * app/gimpdatafactory.[ch]: made some stuff const. * app/gimpdatafactoryview.c: activate the "duplicate" button and set the initial button sensitivity correctly. * app/brush_select.c * app/gradient_select.c * app/pattern_select.c: use the new GimpDataFactoryView. * libgimp/Makefile.am: grouped the file to sort out what _may_ go to subdirs or separate libs. * libgimp/gimpenv.[ch]: added many "const". * app/app_procs.c * app/brush_edit.c * app/gimpcontext.c * app/gimpdnd.c * app/gradient_editor.c * app/palette.c * app/palette_import.c * app/user_install.c: many related changes. * libgimpmath/gimpmathtypes.h * libgimpmath/gimpvector.[ch]: minor cleanups. * plug-ins/script-fu/script-fu.c: gimp_data_directory() is const now.
2001-02-14 22:57:14 +08:00
return GIMP_DATA (brush);
}
void
gimp_brush_generated_freeze (GimpBrushGenerated *brush)
{
g_return_if_fail (GIMP_IS_BRUSH_GENERATED (brush));
brush->freeze++;
}
void
gimp_brush_generated_thaw (GimpBrushGenerated *brush)
{
g_return_if_fail (GIMP_IS_BRUSH_GENERATED (brush));
if (brush->freeze > 0)
brush->freeze--;
Convert ugly comments into named structure fields. Much cleaner and less 2001-12-02 Daniel Egger <degger@fhm.edu> * app/gimprc.c: Convert ugly comments into named structure fields. Much cleaner and less errorprone though may cause troubles on older compilers and then needs to be reverted. Please report! * app/base/base-types.h: Add FIXME reminder. * app/base/gimplut.c: Use CLAMP macro instead of if-cascade. * app/base/temp-buf.c: Remove duplicated calculations and simplify checks. * app/base/tile-manager.c: - (tile_manager_get_tile_num): Return success and take an additional pointer for the tilenumber. - Simplify logic in the rest of the file as a result. - Remove rotten debugging cruft. * app/core/gimpbrushgenerated.c: Fix two stylistic nits. * app/app_procs.c: Include <stdlib.h> for exit () prototype. * app/core/gimpdrawable-blend.c: Include <stdlib.h> for abs () prototype. * app/display/gimpdisplay.c: Include <string.h> for memcpy () prototype. * app/core/gimpimage-convert.c: (HIST_RGB): First parameter is not const. Fixes a gcc warning for a wrong return value. * libgimpwidgets/gimpunitmenu.c * app/core/gimpunit.c: Add suggested (by gcc 3.1 cvs) parentheses to group correct logic tests together. * app/paint-funcs/paint-funcs-generic.h: Fix my HAS_ALPHA macro to avoid gcc 3.1 cvs warning. * app/gimprc.h * pathP.h * base-config.h * app/base/boundary.h * app/base/gimplut.[ch] * app/base/pixel-region.h * app/base/pixel-surround.[ch] * app/base/temp-buf.[ch] * app/base/tile-manager-private.h * app/base/tile-manager.c * app/base/tile-private.h * app/base/tile.[ch] * app/core/gimp.h * app/core/gimpbrushgenerated.h * app/core/gimpbrushpipe.h * app/core/gimpchannel.[ch] * app/core/gimpcontainer.h * app/core/gimpcoreconfig.h * app/core/gimpdata.h * app/core/gimpdatafactory.[ch] * app/core/gimpdrawable-blend.c * app/core/gimpdrawable.[ch] * app/core/gimpimage.h * app/core/gimpimagefile.h * app/core/gimplayer.h * app/core/gimplayermask.h * app/core/gimpmoduleinfo.h * app/core/gimppalette.h * app/core/gimpundo.h * app/display/gimpdisplay.h * app/display/gimpdisplayshell-selection.h * app/display/gimpdisplayshell.h * app/gui/brush-select.h * app/gui/gradient-editor.h * app/gui/gradient-select.h * app/gui/info-dialog.h * app/gui/resize-dialog.h * app/tools/gimpbezierselecttool.h * app/tools/gimpcolorbalancetool.h * app/tools/gimpcolorpickertool.h * app/tools/gimpcurvestool.h * app/tools/gimpdodgeburntool.c * app/tools/gimpfreeselecttool.h * app/tools/gimpfuzzyselecttool.h * app/tools/gimphuesaturationtool.h * app/tools/gimpinktool-blob.h * app/tools/gimpinktool.h * app/tools/gimpiscissorstool.h * app/tools/gimpmagnifytool.h * app/tools/gimpmeasuretool.h * app/tools/gimppainttool.h * app/tools/gimppathtool.h * app/tools/gimprectselecttool.h * app/tools/gimpthresholdtool.h * app/tools/gimptool.h * app/tools/gimptransformtool.h * app/tools/path_toolP.h * app/widgets/gimpbrushfactoryview.h * app/widgets/gimpconstrainedhwrapbox.h * app/widgets/gimpcontainermenu.h * app/widgets/gimpcontainerview.h * app/widgets/gimpdialogfactory.h * app/widgets/gimpimagedock.h * app/widgets/gimplistitem.h * app/widgets/gimpmenuitem.h * app/widgets/gimpnavigationpreview.h * app/widgets/gimppreview.h: Unsignify lots of variables and parameters and use bitfields in structs where possible. First part of a huge cleanup all over the code...
2001-12-02 22:59:30 +08:00
if (!brush->freeze)
gimp_data_dirty (GIMP_DATA (brush));
}
1999-10-27 02:27:27 +08:00
gfloat
gimp_brush_generated_set_radius (GimpBrushGenerated *brush,
gfloat radius)
{
1999-10-27 02:27:27 +08:00
g_return_val_if_fail (GIMP_IS_BRUSH_GENERATED (brush), -1.0);
if (radius < 0.0)
radius = 0.0;
else if (radius > 32767.0)
radius = 32767.0;
if (radius == brush->radius)
return radius;
brush->radius = radius;
Convert ugly comments into named structure fields. Much cleaner and less 2001-12-02 Daniel Egger <degger@fhm.edu> * app/gimprc.c: Convert ugly comments into named structure fields. Much cleaner and less errorprone though may cause troubles on older compilers and then needs to be reverted. Please report! * app/base/base-types.h: Add FIXME reminder. * app/base/gimplut.c: Use CLAMP macro instead of if-cascade. * app/base/temp-buf.c: Remove duplicated calculations and simplify checks. * app/base/tile-manager.c: - (tile_manager_get_tile_num): Return success and take an additional pointer for the tilenumber. - Simplify logic in the rest of the file as a result. - Remove rotten debugging cruft. * app/core/gimpbrushgenerated.c: Fix two stylistic nits. * app/app_procs.c: Include <stdlib.h> for exit () prototype. * app/core/gimpdrawable-blend.c: Include <stdlib.h> for abs () prototype. * app/display/gimpdisplay.c: Include <string.h> for memcpy () prototype. * app/core/gimpimage-convert.c: (HIST_RGB): First parameter is not const. Fixes a gcc warning for a wrong return value. * libgimpwidgets/gimpunitmenu.c * app/core/gimpunit.c: Add suggested (by gcc 3.1 cvs) parentheses to group correct logic tests together. * app/paint-funcs/paint-funcs-generic.h: Fix my HAS_ALPHA macro to avoid gcc 3.1 cvs warning. * app/gimprc.h * pathP.h * base-config.h * app/base/boundary.h * app/base/gimplut.[ch] * app/base/pixel-region.h * app/base/pixel-surround.[ch] * app/base/temp-buf.[ch] * app/base/tile-manager-private.h * app/base/tile-manager.c * app/base/tile-private.h * app/base/tile.[ch] * app/core/gimp.h * app/core/gimpbrushgenerated.h * app/core/gimpbrushpipe.h * app/core/gimpchannel.[ch] * app/core/gimpcontainer.h * app/core/gimpcoreconfig.h * app/core/gimpdata.h * app/core/gimpdatafactory.[ch] * app/core/gimpdrawable-blend.c * app/core/gimpdrawable.[ch] * app/core/gimpimage.h * app/core/gimpimagefile.h * app/core/gimplayer.h * app/core/gimplayermask.h * app/core/gimpmoduleinfo.h * app/core/gimppalette.h * app/core/gimpundo.h * app/display/gimpdisplay.h * app/display/gimpdisplayshell-selection.h * app/display/gimpdisplayshell.h * app/gui/brush-select.h * app/gui/gradient-editor.h * app/gui/gradient-select.h * app/gui/info-dialog.h * app/gui/resize-dialog.h * app/tools/gimpbezierselecttool.h * app/tools/gimpcolorbalancetool.h * app/tools/gimpcolorpickertool.h * app/tools/gimpcurvestool.h * app/tools/gimpdodgeburntool.c * app/tools/gimpfreeselecttool.h * app/tools/gimpfuzzyselecttool.h * app/tools/gimphuesaturationtool.h * app/tools/gimpinktool-blob.h * app/tools/gimpinktool.h * app/tools/gimpiscissorstool.h * app/tools/gimpmagnifytool.h * app/tools/gimpmeasuretool.h * app/tools/gimppainttool.h * app/tools/gimppathtool.h * app/tools/gimprectselecttool.h * app/tools/gimpthresholdtool.h * app/tools/gimptool.h * app/tools/gimptransformtool.h * app/tools/path_toolP.h * app/widgets/gimpbrushfactoryview.h * app/widgets/gimpconstrainedhwrapbox.h * app/widgets/gimpcontainermenu.h * app/widgets/gimpcontainerview.h * app/widgets/gimpdialogfactory.h * app/widgets/gimpimagedock.h * app/widgets/gimplistitem.h * app/widgets/gimpmenuitem.h * app/widgets/gimpnavigationpreview.h * app/widgets/gimppreview.h: Unsignify lots of variables and parameters and use bitfields in structs where possible. First part of a huge cleanup all over the code...
2001-12-02 22:59:30 +08:00
if (!brush->freeze)
gimp_data_dirty (GIMP_DATA (brush));
return brush->radius;
}
1999-10-27 02:27:27 +08:00
gfloat
gimp_brush_generated_set_hardness (GimpBrushGenerated *brush,
gfloat hardness)
{
1999-10-27 02:27:27 +08:00
g_return_val_if_fail (GIMP_IS_BRUSH_GENERATED (brush), -1.0);
if (hardness < 0.0)
hardness = 0.0;
else if (hardness > 1.0)
hardness = 1.0;
if (brush->hardness == hardness)
return hardness;
brush->hardness = hardness;
if (!brush->freeze)
gimp_data_dirty (GIMP_DATA (brush));
return brush->hardness;
}
1999-10-27 02:27:27 +08:00
gfloat
gimp_brush_generated_set_angle (GimpBrushGenerated *brush,
gfloat angle)
{
1999-10-27 02:27:27 +08:00
g_return_val_if_fail (GIMP_IS_BRUSH_GENERATED (brush), -1.0);
if (angle < 0.0)
1999-10-27 02:27:27 +08:00
angle = -1.0 * fmod (angle, 180.0);
else if (angle > 180.0)
1999-10-27 02:27:27 +08:00
angle = fmod (angle, 180.0);
if (brush->angle == angle)
return angle;
brush->angle = angle;
if (!brush->freeze)
gimp_data_dirty (GIMP_DATA (brush));
return brush->angle;
}
1999-10-27 02:27:27 +08:00
gfloat
gimp_brush_generated_set_aspect_ratio (GimpBrushGenerated *brush,
gfloat ratio)
{
1999-10-27 02:27:27 +08:00
g_return_val_if_fail (GIMP_IS_BRUSH_GENERATED (brush), -1.0);
if (ratio < 1.0)
ratio = 1.0;
else if (ratio > 1000)
ratio = 1000;
if (brush->aspect_ratio == ratio)
return ratio;
brush->aspect_ratio = ratio;
if (!brush->freeze)
gimp_data_dirty (GIMP_DATA (brush));
return brush->aspect_ratio;
}
1999-10-27 02:27:27 +08:00
gfloat
gimp_brush_generated_get_radius (const GimpBrushGenerated *brush)
{
1999-10-27 02:27:27 +08:00
g_return_val_if_fail (GIMP_IS_BRUSH_GENERATED (brush), -1.0);
return brush->radius;
}
1999-10-27 02:27:27 +08:00
gfloat
gimp_brush_generated_get_hardness (const GimpBrushGenerated *brush)
{
1999-10-27 02:27:27 +08:00
g_return_val_if_fail (GIMP_IS_BRUSH_GENERATED (brush), -1.0);
return brush->hardness;
}
1999-10-27 02:27:27 +08:00
gfloat
gimp_brush_generated_get_angle (const GimpBrushGenerated *brush)
{
1999-10-27 02:27:27 +08:00
g_return_val_if_fail (GIMP_IS_BRUSH_GENERATED (brush), -1.0);
return brush->angle;
}
1999-10-27 02:27:27 +08:00
gfloat
gimp_brush_generated_get_aspect_ratio (const GimpBrushGenerated *brush)
{
1999-10-27 02:27:27 +08:00
g_return_val_if_fail (GIMP_IS_BRUSH_GENERATED (brush), -1.0);
return brush->aspect_ratio;
}