1998-07-09 13:31:06 +08:00
|
|
|
/* 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.
|
|
|
|
*/
|
2000-09-29 20:00:00 +08:00
|
|
|
|
1999-02-21 07:20:54 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2002-12-02 21:39:09 +08:00
|
|
|
#include <errno.h>
|
1999-02-21 07:20:54 +08:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
#include <glib-object.h>
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2004-01-19 09:54:11 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2001-01-24 07:56:18 +08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
|
|
|
|
2001-05-10 06:34:59 +08:00
|
|
|
#include "core-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-05-15 19:25:25 +08:00
|
|
|
#include "base/temp-buf.h"
|
|
|
|
|
1998-07-09 13:31:06 +08:00
|
|
|
#include "gimpbrushgenerated.h"
|
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2002-12-02 21:39:09 +08:00
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
|
1998-07-09 13:31:06 +08:00
|
|
|
#define OVERSAMPLING 5
|
|
|
|
|
2000-09-29 20:00:00 +08:00
|
|
|
|
2004-06-25 08:58:43 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_RADIUS,
|
|
|
|
PROP_HARDNESS,
|
2004-06-25 21:41:24 +08:00
|
|
|
PROP_ASPECT_RATIO,
|
|
|
|
PROP_ANGLE
|
2004-06-25 08:58:43 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2001-02-11 09:39:24 +08:00
|
|
|
/* local function prototypes */
|
2004-01-30 00:19:57 +08:00
|
|
|
|
2001-05-10 06:34:59 +08:00
|
|
|
static void gimp_brush_generated_class_init (GimpBrushGeneratedClass *klass);
|
|
|
|
static void gimp_brush_generated_init (GimpBrushGenerated *brush);
|
|
|
|
|
2004-06-25 21:41:24 +08:00
|
|
|
static void gimp_brush_generated_set_property (GObject *object,
|
2004-06-25 08:58:43 +08:00
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
2004-06-25 21:41:24 +08:00
|
|
|
static void gimp_brush_generated_get_property (GObject *object,
|
2004-06-25 08:58:43 +08:00
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
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);
|
1998-07-15 20:15:24 +08:00
|
|
|
|
2000-09-29 20:00:00 +08:00
|
|
|
|
2001-01-10 08:36:54 +08:00
|
|
|
static GimpBrushClass *parent_class = NULL;
|
2000-09-29 20:00:00 +08:00
|
|
|
|
1998-07-09 13:31:06 +08:00
|
|
|
|
2001-08-11 22:39:19 +08:00
|
|
|
GType
|
1999-10-27 02:27:27 +08:00
|
|
|
gimp_brush_generated_get_type (void)
|
1998-07-09 13:31:06 +08:00
|
|
|
{
|
2001-08-11 22:39:19 +08:00
|
|
|
static GType brush_type = 0;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-08-11 22:39:19 +08:00
|
|
|
if (! brush_type)
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
2001-08-11 22:39:19 +08:00
|
|
|
static const GTypeInfo brush_info =
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
2001-08-11 22:39:19 +08:00
|
|
|
sizeof (GimpBrushGeneratedClass),
|
2004-01-30 00:19:57 +08:00
|
|
|
(GBaseInitFunc) NULL,
|
|
|
|
(GBaseFinalizeFunc) NULL,
|
|
|
|
(GClassInitFunc) gimp_brush_generated_class_init,
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
|
|
|
sizeof (GimpBrushGenerated),
|
|
|
|
0, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) gimp_brush_generated_init,
|
1999-10-27 02:27:27 +08:00
|
|
|
};
|
|
|
|
|
2001-08-11 22:39:19 +08:00
|
|
|
brush_type = g_type_register_static (GIMP_TYPE_BRUSH,
|
2004-01-30 00:19:57 +08:00
|
|
|
"GimpBrushGenerated",
|
|
|
|
&brush_info, 0);
|
1999-10-27 02:27:27 +08:00
|
|
|
}
|
|
|
|
|
2001-08-11 22:39:19 +08:00
|
|
|
return brush_type;
|
1998-07-09 13:31:06 +08:00
|
|
|
}
|
|
|
|
|
2001-02-11 09:39:24 +08:00
|
|
|
static void
|
|
|
|
gimp_brush_generated_class_init (GimpBrushGeneratedClass *klass)
|
1998-07-09 13:31:06 +08:00
|
|
|
{
|
2004-06-25 08:58:43 +08:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GimpDataClass *data_class = GIMP_DATA_CLASS (klass);
|
1998-07-09 13:31:06 +08:00
|
|
|
|
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);
|
1998-07-09 13:31:06 +08:00
|
|
|
|
2004-06-25 08:58:43 +08:00
|
|
|
object_class->set_property = gimp_brush_generated_set_property;
|
|
|
|
object_class->get_property = gimp_brush_generated_get_property;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_RADIUS,
|
|
|
|
g_param_spec_double ("radius", NULL, NULL,
|
|
|
|
1.0, 1000.0, 5.0,
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT));
|
|
|
|
g_object_class_install_property (object_class, PROP_HARDNESS,
|
|
|
|
g_param_spec_double ("hardness", NULL, NULL,
|
|
|
|
0.0, 1.0, 0.0,
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT));
|
|
|
|
g_object_class_install_property (object_class, PROP_ASPECT_RATIO,
|
|
|
|
g_param_spec_double ("aspect-ratio",
|
|
|
|
NULL, NULL,
|
|
|
|
1.0, 20.0, 1.0,
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT));
|
2004-06-25 21:41:24 +08:00
|
|
|
g_object_class_install_property (object_class, PROP_ANGLE,
|
|
|
|
g_param_spec_double ("angle", NULL, NULL,
|
|
|
|
0.0, 180.0, 0.0,
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT));
|
1998-07-16 19:44:56 +08:00
|
|
|
}
|
|
|
|
|
2001-02-11 09:39:24 +08:00
|
|
|
static void
|
|
|
|
gimp_brush_generated_init (GimpBrushGenerated *brush)
|
1998-07-16 19:44:56 +08:00
|
|
|
{
|
2001-02-11 09:39:24 +08:00
|
|
|
brush->radius = 5.0;
|
|
|
|
brush->hardness = 0.0;
|
|
|
|
brush->aspect_ratio = 1.0;
|
2004-06-25 21:41:24 +08:00
|
|
|
brush->angle = 0.0;
|
1998-07-09 13:31:06 +08:00
|
|
|
}
|
|
|
|
|
2004-06-25 08:58:43 +08:00
|
|
|
static void
|
|
|
|
gimp_brush_generated_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GimpBrushGenerated *brush = GIMP_BRUSH_GENERATED (object);
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_RADIUS:
|
|
|
|
gimp_brush_generated_set_radius (brush, g_value_get_double (value));
|
|
|
|
break;
|
|
|
|
case PROP_HARDNESS:
|
2004-06-25 21:41:24 +08:00
|
|
|
gimp_brush_generated_set_hardness (brush, g_value_get_double (value));
|
2004-06-25 08:58:43 +08:00
|
|
|
break;
|
|
|
|
case PROP_ASPECT_RATIO:
|
2004-06-25 21:41:24 +08:00
|
|
|
gimp_brush_generated_set_aspect_ratio (brush, g_value_get_double (value));
|
|
|
|
break;
|
|
|
|
case PROP_ANGLE:
|
|
|
|
gimp_brush_generated_set_angle (brush, g_value_get_double (value));
|
2004-06-25 08:58:43 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_brush_generated_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GimpBrushGenerated *brush = GIMP_BRUSH_GENERATED (object);
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_RADIUS:
|
|
|
|
g_value_set_double (value, brush->angle);
|
|
|
|
break;
|
|
|
|
case PROP_HARDNESS:
|
|
|
|
g_value_set_double (value, brush->hardness);
|
|
|
|
break;
|
|
|
|
case PROP_ASPECT_RATIO:
|
|
|
|
g_value_set_double (value, brush->aspect_ratio);
|
|
|
|
break;
|
2004-06-25 21:41:24 +08:00
|
|
|
case PROP_ANGLE:
|
|
|
|
g_value_set_double (value, brush->angle);
|
|
|
|
break;
|
2004-06-25 08:58:43 +08:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-11 09:39:24 +08:00
|
|
|
static gboolean
|
2002-12-02 21:39:09 +08:00
|
|
|
gimp_brush_generated_save (GimpData *data,
|
|
|
|
GError **error)
|
2001-02-11 09:39:24 +08:00
|
|
|
{
|
2004-01-30 00:19:57 +08:00
|
|
|
GimpBrushGenerated *brush = GIMP_BRUSH_GENERATED (data);
|
|
|
|
FILE *file;
|
2001-10-29 20:51:21 +08:00
|
|
|
gchar buf[G_ASCII_DTOSTR_BUF_SIZE];
|
2001-02-05 01:34:30 +08:00
|
|
|
|
2004-01-30 00:19:57 +08:00
|
|
|
file = fopen (data->filename, "wb");
|
2001-02-05 01:34:30 +08:00
|
|
|
|
2004-01-30 00:19:57 +08:00
|
|
|
if (! file)
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
2002-12-02 21:39:09 +08:00
|
|
|
g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_OPEN,
|
|
|
|
_("Could not open '%s' for writing: %s"),
|
2004-01-19 09:08:43 +08:00
|
|
|
gimp_filename_to_utf8 (data->filename),
|
2004-01-14 10:03:37 +08:00
|
|
|
g_strerror (errno));
|
2001-02-11 09:39:24 +08:00
|
|
|
return FALSE;
|
1999-10-27 02:27:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* write magic header */
|
2004-01-30 00:19:57 +08:00
|
|
|
fprintf (file, "GIMP-VBR\n");
|
1999-10-27 02:27:27 +08:00
|
|
|
|
|
|
|
/* write version */
|
2004-01-30 00:19:57 +08:00
|
|
|
fprintf (file, "1.0\n");
|
1999-10-27 02:27:27 +08:00
|
|
|
|
|
|
|
/* write name */
|
2004-01-30 00:19:57 +08:00
|
|
|
fprintf (file, "%.255s\n", GIMP_OBJECT (brush)->name);
|
1999-10-27 02:27:27 +08:00
|
|
|
|
|
|
|
/* write brush spacing */
|
2004-01-30 00:19:57 +08:00
|
|
|
fprintf (file, "%s\n",
|
2003-11-14 23:33:40 +08:00
|
|
|
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f",
|
2001-10-29 20:51:21 +08:00
|
|
|
GIMP_BRUSH (brush)->spacing));
|
1999-10-27 02:27:27 +08:00
|
|
|
|
|
|
|
/* write brush radius */
|
2004-01-30 00:19:57 +08:00
|
|
|
fprintf (file, "%s\n",
|
2003-11-14 23:33:40 +08:00
|
|
|
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f",
|
2001-10-29 20:51:21 +08:00
|
|
|
brush->radius));
|
1999-10-27 02:27:27 +08:00
|
|
|
|
|
|
|
/* write brush hardness */
|
2004-01-30 00:19:57 +08:00
|
|
|
fprintf (file, "%s\n",
|
2003-11-14 23:33:40 +08:00
|
|
|
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f",
|
2001-10-29 20:51:21 +08:00
|
|
|
brush->hardness));
|
1999-10-27 02:27:27 +08:00
|
|
|
|
|
|
|
/* write brush aspect_ratio */
|
2004-01-30 00:19:57 +08:00
|
|
|
fprintf (file, "%s\n",
|
2003-11-14 23:33:40 +08:00
|
|
|
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f",
|
2001-10-29 20:51:21 +08:00
|
|
|
brush->aspect_ratio));
|
1999-10-27 02:27:27 +08:00
|
|
|
|
|
|
|
/* write brush angle */
|
2004-01-30 00:19:57 +08:00
|
|
|
fprintf (file, "%s\n",
|
2003-11-14 23:33:40 +08:00
|
|
|
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f",
|
2001-10-29 20:51:21 +08:00
|
|
|
brush->angle));
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2004-01-30 00:19:57 +08:00
|
|
|
fclose (file);
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-02-11 09:39:24 +08:00
|
|
|
return TRUE;
|
1998-07-15 20:15:24 +08:00
|
|
|
}
|
1998-07-25 18:20:07 +08:00
|
|
|
|
2001-02-14 03:53:07 +08:00
|
|
|
static gchar *
|
|
|
|
gimp_brush_generated_get_extension (GimpData *data)
|
|
|
|
{
|
|
|
|
return GIMP_BRUSH_GENERATED_FILE_EXTENSION;
|
|
|
|
}
|
|
|
|
|
2001-02-19 03:44:28 +08:00
|
|
|
static GimpData *
|
2002-12-01 00:31:39 +08:00
|
|
|
gimp_brush_generated_duplicate (GimpData *data,
|
|
|
|
gboolean stingy_memory_use)
|
2001-02-19 03:44:28 +08:00
|
|
|
{
|
2004-01-30 00:19:57 +08:00
|
|
|
GimpBrushGenerated *brush = GIMP_BRUSH_GENERATED (data);
|
2001-02-19 03:44:28 +08:00
|
|
|
|
2004-01-30 00:19:57 +08:00
|
|
|
return gimp_brush_generated_new (GIMP_OBJECT (brush)->name,
|
|
|
|
brush->radius,
|
2001-02-19 03:44:28 +08:00
|
|
|
brush->hardness,
|
2002-12-01 00:31:39 +08:00
|
|
|
brush->aspect_ratio,
|
2004-06-25 21:41:24 +08:00
|
|
|
brush->angle,
|
2002-12-01 00:31:39 +08:00
|
|
|
stingy_memory_use);
|
2001-02-19 03:44:28 +08:00
|
|
|
}
|
|
|
|
|
2003-04-09 23:31:45 +08:00
|
|
|
static gdouble
|
1999-10-27 02:27:27 +08:00
|
|
|
gauss (gdouble f)
|
2003-11-14 23:33:40 +08:00
|
|
|
{
|
1999-10-27 02:27:27 +08:00
|
|
|
/* this aint' a real gauss function */
|
2003-04-09 23:31:45 +08:00
|
|
|
if (f < -0.5)
|
1998-07-24 16:56:18 +08:00
|
|
|
{
|
2000-09-29 20:00:00 +08:00
|
|
|
f = -1.0 - f;
|
2000-02-24 19:39:26 +08:00
|
|
|
return (2.0 * f*f);
|
1998-07-24 16:56:18 +08:00
|
|
|
}
|
2000-09-29 20:00:00 +08:00
|
|
|
|
2003-04-09 23:31:45 +08:00
|
|
|
if (f < 0.5)
|
2000-02-24 19:39:26 +08:00
|
|
|
return (1.0 - 2.0 * f*f);
|
2000-09-29 20:00:00 +08:00
|
|
|
|
2003-04-09 23:31:45 +08:00
|
|
|
f = 1.0 - f;
|
2000-02-24 19:39:26 +08:00
|
|
|
return (2.0 * f*f);
|
1998-07-24 16:56:18 +08:00
|
|
|
}
|
1998-07-15 20:15:24 +08:00
|
|
|
|
2001-02-11 09:39:24 +08:00
|
|
|
static void
|
|
|
|
gimp_brush_generated_dirty (GimpData *data)
|
1998-07-09 13:31:06 +08:00
|
|
|
{
|
2004-01-30 00:19:57 +08:00
|
|
|
GimpBrushGenerated *brush = GIMP_BRUSH_GENERATED (data);
|
|
|
|
GimpBrush *gbrush = GIMP_BRUSH (brush);
|
|
|
|
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];
|
2001-02-11 09:39:24 +08:00
|
|
|
|
1998-07-09 13:31:06 +08:00
|
|
|
if (gbrush->mask)
|
2003-04-09 23:31:45 +08:00
|
|
|
temp_buf_free (gbrush->mask);
|
2000-09-29 20:00:00 +08:00
|
|
|
|
2000-02-19 02:20:04 +08:00
|
|
|
s = sin (gimp_deg_to_rad (brush->angle));
|
|
|
|
c = cos (gimp_deg_to_rad (brush->angle));
|
2000-09-29 20:00:00 +08:00
|
|
|
|
2003-04-09 23:31:45 +08:00
|
|
|
short_radius = brush->radius / brush->aspect_ratio;
|
2000-09-29 20:00:00 +08:00
|
|
|
|
2003-04-09 23:31:45 +08:00
|
|
|
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;
|
2003-11-14 23:33:40 +08:00
|
|
|
|
2003-04-09 23:31:45 +08:00
|
|
|
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,
|
2000-09-29 20:00:00 +08:00
|
|
|
height * 2 + 1,
|
1999-10-27 02:27:27 +08:00
|
|
|
1, width, height, 0);
|
2003-04-09 23:31:45 +08:00
|
|
|
|
|
|
|
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)));
|
2000-09-29 20:00:00 +08:00
|
|
|
|
1998-07-09 13:31:06 +08:00
|
|
|
if ((1.0 - brush->hardness) < 0.000001)
|
2003-11-14 23:33:40 +08:00
|
|
|
exponent = 1000000.0;
|
1998-07-09 13:31:06 +08:00
|
|
|
else
|
2003-04-09 23:31:45 +08:00
|
|
|
exponent = 1.0 / (1.0 - brush->hardness);
|
2000-09-29 20:00:00 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
lookup = g_malloc (length);
|
1998-07-09 13:31:06 +08:00
|
|
|
sum = 0.0;
|
2000-09-29 20:00:00 +08:00
|
|
|
|
1998-07-09 13:31:06 +08:00
|
|
|
for (x = 0; x < OVERSAMPLING; x++)
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
2000-09-29 20:00:00 +08:00
|
|
|
d = fabs ((x + 0.5) / OVERSAMPLING - 0.5);
|
2003-04-09 23:31:45 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
if (d > brush->radius)
|
2000-09-29 20:00:00 +08:00
|
|
|
buffer[x] = 0.0;
|
|
|
|
else
|
2003-04-09 23:31:45 +08:00
|
|
|
buffer[x] = gauss (pow (d / brush->radius, exponent));
|
|
|
|
|
2000-09-29 20:00:00 +08:00
|
|
|
sum += buffer[x];
|
|
|
|
}
|
|
|
|
|
|
|
|
for (x = 0; d < brush->radius || sum > 0.00001; d += 1.0 / OVERSAMPLING)
|
|
|
|
{
|
|
|
|
sum -= buffer[x % OVERSAMPLING];
|
2003-04-09 23:31:45 +08:00
|
|
|
|
2000-09-29 20:00:00 +08:00
|
|
|
if (d > brush->radius)
|
|
|
|
buffer[x % OVERSAMPLING] = 0.0;
|
1999-10-27 02:27:27 +08:00
|
|
|
else
|
2003-04-09 23:31:45 +08:00
|
|
|
buffer[x % OVERSAMPLING] = gauss (pow (d / brush->radius, exponent));
|
|
|
|
|
|
|
|
sum += buffer[x % OVERSAMPLING];
|
2000-09-29 20:00:00 +08:00
|
|
|
lookup[x++] = RINT (sum * (255.0 / OVERSAMPLING));
|
1999-10-27 02:27:27 +08:00
|
|
|
}
|
2003-04-09 23:31:45 +08:00
|
|
|
|
1998-07-09 13:31:06 +08:00
|
|
|
while (x < length)
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
|
|
|
lookup[x++] = 0;
|
|
|
|
}
|
2003-04-09 23:31:45 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
/* compute one half and mirror it */
|
1998-07-09 13:31:06 +08:00
|
|
|
for (y = 0; y <= height; y++)
|
|
|
|
{
|
1999-10-27 02:27:27 +08:00
|
|
|
for (x = -width; x <= width; x++)
|
|
|
|
{
|
2003-04-09 23:31:45 +08:00
|
|
|
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);
|
2003-04-09 23:31:45 +08:00
|
|
|
|
|
|
|
if (d < brush->radius + 1)
|
2000-09-29 20:00:00 +08:00
|
|
|
a = lookup[(gint) RINT (d * OVERSAMPLING)];
|
1999-10-27 02:27:27 +08:00
|
|
|
else
|
|
|
|
a = 0;
|
2003-04-09 23:31:45 +08:00
|
|
|
|
|
|
|
centerp[ y * gbrush->mask->width + x] = a;
|
|
|
|
centerp[-1 * y * gbrush->mask->width - x] = a;
|
1999-10-27 02:27:27 +08:00
|
|
|
}
|
1998-07-09 13:31:06 +08:00
|
|
|
}
|
2001-02-07 11:14:38 +08:00
|
|
|
|
1998-07-09 13:31:06 +08:00
|
|
|
g_free (lookup);
|
2000-09-29 20:00:00 +08:00
|
|
|
|
2001-02-11 09:39:24 +08:00
|
|
|
if (GIMP_DATA_CLASS (parent_class)->dirty)
|
|
|
|
GIMP_DATA_CLASS (parent_class)->dirty (data);
|
1998-07-09 13:31:06 +08:00
|
|
|
}
|
|
|
|
|
2001-02-14 22:57:14 +08:00
|
|
|
GimpData *
|
2004-01-30 00:19:57 +08:00
|
|
|
gimp_brush_generated_new (const gchar *name,
|
|
|
|
gfloat radius,
|
|
|
|
gfloat hardness,
|
|
|
|
gfloat aspect_ratio,
|
2004-06-25 21:41:24 +08:00
|
|
|
gfloat angle,
|
2004-01-30 00:19:57 +08:00
|
|
|
gboolean stingy_memory_use)
|
2001-02-11 09:39:24 +08:00
|
|
|
{
|
|
|
|
GimpBrushGenerated *brush;
|
|
|
|
|
2004-01-30 00:19:57 +08:00
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
2001-02-11 09:39:24 +08:00
|
|
|
|
2004-01-30 00:19:57 +08:00
|
|
|
brush = g_object_new (GIMP_TYPE_BRUSH_GENERATED,
|
2004-06-25 21:41:24 +08:00
|
|
|
"name", name,
|
|
|
|
"radius", radius,
|
|
|
|
"hardness", hardness,
|
|
|
|
"aspect-ratio", aspect_ratio,
|
|
|
|
"angle", angle,
|
2004-01-30 00:19:57 +08:00
|
|
|
NULL);
|
2001-02-11 09:39:24 +08:00
|
|
|
|
|
|
|
GIMP_BRUSH (brush)->spacing = 20;
|
|
|
|
|
|
|
|
/* render brush mask */
|
|
|
|
gimp_data_dirty (GIMP_DATA (brush));
|
|
|
|
|
2002-12-01 00:31:39 +08:00
|
|
|
if (stingy_memory_use)
|
|
|
|
temp_buf_swap (GIMP_BRUSH (brush)->mask);
|
|
|
|
|
2001-02-14 22:57:14 +08:00
|
|
|
return GIMP_DATA (brush);
|
2001-02-11 09:39:24 +08:00
|
|
|
}
|
|
|
|
|
2004-07-27 03:00:22 +08:00
|
|
|
GList *
|
2002-12-02 21:39:09 +08:00
|
|
|
gimp_brush_generated_load (const gchar *filename,
|
|
|
|
gboolean stingy_memory_use,
|
|
|
|
GError **error)
|
2001-02-11 09:39:24 +08:00
|
|
|
{
|
|
|
|
GimpBrushGenerated *brush;
|
2004-01-30 00:19:57 +08:00
|
|
|
FILE *file;
|
2001-02-14 22:57:14 +08:00
|
|
|
gchar string[256];
|
2004-06-25 21:41:24 +08:00
|
|
|
gchar *name = NULL;
|
|
|
|
gdouble spacing;
|
|
|
|
gdouble radius;
|
|
|
|
gdouble hardness;
|
|
|
|
gdouble aspect_ratio;
|
|
|
|
gdouble angle;
|
2001-02-11 09:39:24 +08:00
|
|
|
|
2002-12-02 21:39:09 +08:00
|
|
|
g_return_val_if_fail (filename != NULL, NULL);
|
2004-01-30 00:19:57 +08:00
|
|
|
g_return_val_if_fail (g_path_is_absolute (filename), NULL);
|
2002-12-02 21:39:09 +08:00
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
|
|
|
|
2004-01-30 00:19:57 +08:00
|
|
|
file = fopen (filename, "rb");
|
|
|
|
|
|
|
|
if (! file)
|
2002-12-02 21:39:09 +08:00
|
|
|
{
|
|
|
|
g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_OPEN,
|
|
|
|
_("Could not open '%s' for reading: %s"),
|
2004-01-19 09:08:43 +08:00
|
|
|
gimp_filename_to_utf8 (filename), g_strerror (errno));
|
2002-12-02 21:39:09 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
2001-02-11 09:39:24 +08:00
|
|
|
|
|
|
|
/* make sure the file we are reading is the right type */
|
2004-06-25 21:41:24 +08:00
|
|
|
errno = 0;
|
|
|
|
if (! fgets (string, sizeof (string), file))
|
|
|
|
goto failed;
|
2002-12-02 21:39:09 +08:00
|
|
|
|
2001-02-11 09:39:24 +08:00
|
|
|
if (strncmp (string, "GIMP-VBR", 8) != 0)
|
2002-12-02 21:39:09 +08:00
|
|
|
{
|
|
|
|
g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
|
2003-11-14 23:33:40 +08:00
|
|
|
_("Fatal parse error in brush file '%s': "
|
|
|
|
"Not a GIMP brush file."),
|
2004-01-19 09:08:43 +08:00
|
|
|
gimp_filename_to_utf8 (filename));
|
2002-12-02 21:39:09 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
2001-02-14 22:57:14 +08:00
|
|
|
|
2001-02-11 09:39:24 +08:00
|
|
|
/* make sure we are reading a compatible version */
|
2004-06-25 21:41:24 +08:00
|
|
|
errno = 0;
|
|
|
|
if (! fgets (string, sizeof (string), file))
|
|
|
|
goto failed;
|
|
|
|
|
2001-10-29 20:51:21 +08:00
|
|
|
if (strncmp (string, "1.0", 3))
|
2002-12-02 21:39:09 +08:00
|
|
|
{
|
|
|
|
g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
|
2003-11-14 23:33:40 +08:00
|
|
|
_("Fatal parse error in brush file '%s': "
|
|
|
|
"Unknown GIMP brush version."),
|
2004-01-19 09:08:43 +08:00
|
|
|
gimp_filename_to_utf8 (filename));
|
2002-12-02 21:39:09 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
2001-02-11 09:39:24 +08:00
|
|
|
|
2004-01-30 00:19:57 +08:00
|
|
|
/* read name */
|
2004-06-25 21:41:24 +08:00
|
|
|
errno = 0;
|
|
|
|
if (! fgets (string, sizeof (string), file))
|
|
|
|
goto failed;
|
2001-02-11 09:39:24 +08:00
|
|
|
|
2004-06-25 21:41:24 +08:00
|
|
|
g_strstrip (string);
|
|
|
|
name = gimp_any_to_utf8 (string, -1,
|
|
|
|
_("Invalid UTF-8 string in brush file '%s'."),
|
|
|
|
gimp_filename_to_utf8 (filename));
|
2001-02-11 09:39:24 +08:00
|
|
|
|
|
|
|
/* read brush spacing */
|
2004-06-25 21:41:24 +08:00
|
|
|
errno = 0;
|
|
|
|
if (! fgets (string, sizeof (string), file))
|
|
|
|
goto failed;
|
|
|
|
spacing = g_ascii_strtod (string, NULL);
|
2001-02-11 09:39:24 +08:00
|
|
|
|
|
|
|
/* read brush radius */
|
2004-06-25 21:41:24 +08:00
|
|
|
errno = 0;
|
|
|
|
if (! fgets (string, sizeof (string), file))
|
|
|
|
goto failed;
|
|
|
|
radius = g_ascii_strtod (string, NULL);
|
2001-02-11 09:39:24 +08:00
|
|
|
|
|
|
|
/* read brush hardness */
|
2004-06-25 21:41:24 +08:00
|
|
|
errno = 0;
|
|
|
|
if (! fgets (string, sizeof (string), file))
|
|
|
|
goto failed;
|
|
|
|
hardness = g_ascii_strtod (string, NULL);
|
2001-02-11 09:39:24 +08:00
|
|
|
|
|
|
|
/* read brush aspect_ratio */
|
2004-06-25 21:41:24 +08:00
|
|
|
errno = 0;
|
|
|
|
if (! fgets (string, sizeof (string), file))
|
|
|
|
goto failed;
|
|
|
|
aspect_ratio = g_ascii_strtod (string, NULL);
|
2001-02-11 09:39:24 +08:00
|
|
|
|
|
|
|
/* read brush angle */
|
2004-06-25 21:41:24 +08:00
|
|
|
errno = 0;
|
|
|
|
if (! fgets (string, sizeof (string), file))
|
|
|
|
goto failed;
|
|
|
|
angle = g_ascii_strtod (string, NULL);
|
2001-02-11 09:39:24 +08:00
|
|
|
|
2004-01-30 00:19:57 +08:00
|
|
|
fclose (file);
|
2001-02-11 09:39:24 +08:00
|
|
|
|
2004-06-25 21:41:24 +08:00
|
|
|
/* create new brush */
|
|
|
|
brush = g_object_new (GIMP_TYPE_BRUSH_GENERATED,
|
|
|
|
"name", name,
|
|
|
|
"radius", radius,
|
|
|
|
"hardness", hardness,
|
|
|
|
"aspect-ratio", aspect_ratio,
|
|
|
|
"angle", angle,
|
|
|
|
NULL);
|
|
|
|
g_free (name);
|
|
|
|
|
|
|
|
GIMP_BRUSH (brush)->spacing = spacing;
|
|
|
|
|
|
|
|
/* render brush mask */
|
|
|
|
gimp_data_dirty (GIMP_DATA (brush));
|
2001-02-11 09:39:24 +08:00
|
|
|
|
2002-12-01 00:31:39 +08:00
|
|
|
if (stingy_memory_use)
|
2001-02-11 09:39:24 +08:00
|
|
|
temp_buf_swap (GIMP_BRUSH (brush)->mask);
|
|
|
|
|
2004-07-27 03:00:22 +08:00
|
|
|
return g_list_prepend (NULL, brush);
|
2004-06-25 21:41:24 +08:00
|
|
|
|
|
|
|
failed:
|
|
|
|
|
|
|
|
if (name)
|
|
|
|
g_free (name);
|
|
|
|
|
|
|
|
g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
|
|
|
|
_("Error while reading brush file '%s': %s"),
|
|
|
|
gimp_filename_to_utf8 (filename),
|
|
|
|
errno ? g_strerror (errno) : _("File is truncated"));
|
|
|
|
|
|
|
|
return NULL;
|
2001-02-11 09:39:24 +08:00
|
|
|
}
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
gfloat
|
|
|
|
gimp_brush_generated_set_radius (GimpBrushGenerated *brush,
|
|
|
|
gfloat radius)
|
1998-07-09 13:31:06 +08:00
|
|
|
{
|
1999-10-27 02:27:27 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_BRUSH_GENERATED (brush), -1.0);
|
|
|
|
|
2004-01-30 00:19:57 +08:00
|
|
|
radius = CLAMP (radius, 0.0, 32767.0);
|
2000-09-29 20:00:00 +08:00
|
|
|
|
2004-01-30 00:19:57 +08:00
|
|
|
if (brush->radius != radius)
|
|
|
|
{
|
|
|
|
brush->radius = radius;
|
2000-09-29 20:00:00 +08:00
|
|
|
|
2004-06-25 08:58:43 +08:00
|
|
|
g_object_notify (G_OBJECT (brush), "radius");
|
2004-06-13 06:13:31 +08:00
|
|
|
gimp_data_dirty (GIMP_DATA (brush));
|
2004-01-30 00:19:57 +08:00
|
|
|
}
|
2000-09-29 20:00:00 +08:00
|
|
|
|
1998-07-09 13:31:06 +08:00
|
|
|
return brush->radius;
|
|
|
|
}
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
gfloat
|
|
|
|
gimp_brush_generated_set_hardness (GimpBrushGenerated *brush,
|
|
|
|
gfloat hardness)
|
1998-07-09 13:31:06 +08:00
|
|
|
{
|
1999-10-27 02:27:27 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_BRUSH_GENERATED (brush), -1.0);
|
|
|
|
|
2004-01-30 00:19:57 +08:00
|
|
|
hardness = CLAMP (hardness, 0.0, 1.0);
|
2000-09-29 20:00:00 +08:00
|
|
|
|
2004-01-30 00:19:57 +08:00
|
|
|
if (brush->hardness != hardness)
|
|
|
|
{
|
|
|
|
brush->hardness = hardness;
|
2000-09-29 20:00:00 +08:00
|
|
|
|
2004-06-25 08:58:43 +08:00
|
|
|
g_object_notify (G_OBJECT (brush), "hardness");
|
2004-06-13 06:13:31 +08:00
|
|
|
gimp_data_dirty (GIMP_DATA (brush));
|
2004-01-30 00:19:57 +08:00
|
|
|
}
|
2000-09-29 20:00:00 +08:00
|
|
|
|
1998-07-09 13:31:06 +08:00
|
|
|
return brush->hardness;
|
|
|
|
}
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
gfloat
|
2004-06-25 21:41:24 +08:00
|
|
|
gimp_brush_generated_set_aspect_ratio (GimpBrushGenerated *brush,
|
|
|
|
gfloat ratio)
|
1998-07-09 13:31:06 +08:00
|
|
|
{
|
1999-10-27 02:27:27 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_BRUSH_GENERATED (brush), -1.0);
|
|
|
|
|
2004-06-25 21:41:24 +08:00
|
|
|
ratio = CLAMP (ratio, 1.0, 1000.0);
|
2000-09-29 20:00:00 +08:00
|
|
|
|
2004-06-25 21:41:24 +08:00
|
|
|
if (brush->aspect_ratio != ratio)
|
2004-01-30 00:19:57 +08:00
|
|
|
{
|
2004-06-25 21:41:24 +08:00
|
|
|
brush->aspect_ratio = ratio;
|
2000-09-29 20:00:00 +08:00
|
|
|
|
2004-06-25 21:41:24 +08:00
|
|
|
g_object_notify (G_OBJECT (brush), "aspect-ratio");
|
2004-06-13 06:13:31 +08:00
|
|
|
gimp_data_dirty (GIMP_DATA (brush));
|
2004-01-30 00:19:57 +08:00
|
|
|
}
|
2000-09-29 20:00:00 +08:00
|
|
|
|
2004-06-25 21:41:24 +08:00
|
|
|
return brush->aspect_ratio;
|
1998-07-09 13:31:06 +08:00
|
|
|
}
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
gfloat
|
2004-06-25 21:41:24 +08:00
|
|
|
gimp_brush_generated_set_angle (GimpBrushGenerated *brush,
|
|
|
|
gfloat angle)
|
1998-07-09 13:31:06 +08:00
|
|
|
{
|
1999-10-27 02:27:27 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_BRUSH_GENERATED (brush), -1.0);
|
|
|
|
|
2004-06-25 21:41:24 +08:00
|
|
|
if (angle < 0.0)
|
|
|
|
angle = -1.0 * fmod (angle, 180.0);
|
|
|
|
else if (angle > 180.0)
|
|
|
|
angle = fmod (angle, 180.0);
|
2000-09-29 20:00:00 +08:00
|
|
|
|
2004-06-25 21:41:24 +08:00
|
|
|
if (brush->angle != angle)
|
2004-01-30 00:19:57 +08:00
|
|
|
{
|
2004-06-25 21:41:24 +08:00
|
|
|
brush->angle = angle;
|
2000-09-29 20:00:00 +08:00
|
|
|
|
2004-06-25 21:41:24 +08:00
|
|
|
g_object_notify (G_OBJECT (brush), "angle");
|
2004-06-13 06:13:31 +08:00
|
|
|
gimp_data_dirty (GIMP_DATA (brush));
|
2004-01-30 00:19:57 +08:00
|
|
|
}
|
2000-09-29 20:00:00 +08:00
|
|
|
|
2004-06-25 21:41:24 +08:00
|
|
|
return brush->angle;
|
1998-07-09 13:31:06 +08:00
|
|
|
}
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
gfloat
|
|
|
|
gimp_brush_generated_get_radius (const GimpBrushGenerated *brush)
|
1998-07-09 13:31:06 +08:00
|
|
|
{
|
1999-10-27 02:27:27 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_BRUSH_GENERATED (brush), -1.0);
|
|
|
|
|
1998-07-09 13:31:06 +08:00
|
|
|
return brush->radius;
|
|
|
|
}
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
gfloat
|
2000-09-29 20:00:00 +08:00
|
|
|
gimp_brush_generated_get_hardness (const GimpBrushGenerated *brush)
|
1998-07-09 13:31:06 +08:00
|
|
|
{
|
1999-10-27 02:27:27 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_BRUSH_GENERATED (brush), -1.0);
|
|
|
|
|
1998-07-09 13:31:06 +08:00
|
|
|
return brush->hardness;
|
|
|
|
}
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
gfloat
|
2004-06-25 21:41:24 +08:00
|
|
|
gimp_brush_generated_get_aspect_ratio (const GimpBrushGenerated *brush)
|
1998-07-09 13:31:06 +08:00
|
|
|
{
|
1999-10-27 02:27:27 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_BRUSH_GENERATED (brush), -1.0);
|
|
|
|
|
2004-06-25 21:41:24 +08:00
|
|
|
return brush->aspect_ratio;
|
1998-07-09 13:31:06 +08:00
|
|
|
}
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
gfloat
|
2004-06-25 21:41:24 +08:00
|
|
|
gimp_brush_generated_get_angle (const GimpBrushGenerated *brush)
|
1998-07-09 13:31:06 +08:00
|
|
|
{
|
1999-10-27 02:27:27 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_BRUSH_GENERATED (brush), -1.0);
|
|
|
|
|
2004-06-25 21:41:24 +08:00
|
|
|
return brush->angle;
|
1998-07-09 13:31:06 +08:00
|
|
|
}
|