mirror of https://github.com/GNOME/gimp.git
app/gimpbrush.[ch] app/gimpbrushgenerated.[ch] app/gimpbrushlist.[ch]
2000-02-24 Michael Natterer <mitch@gimp.org> * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushlist.[ch] * app/gimpbrushlistP.h * app/gimpbrushpipe.[ch] * app/gimpbrushpipeP.h: did a brushes code-review: indentation, removed some includes, didn't find a bug :-) * app/gradient.c * app/palette.c: we were leaking all gradient and palette preview pixmaps as well as all lists of palette colors on each refresh. * libgimp/gimpenv.c: updated documentation.
This commit is contained in:
parent
ae38b99c21
commit
8f4adbadbf
16
ChangeLog
16
ChangeLog
|
@ -1,3 +1,19 @@
|
|||
2000-02-24 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/gimpbrush.[ch]
|
||||
* app/gimpbrushgenerated.[ch]
|
||||
* app/gimpbrushlist.[ch]
|
||||
* app/gimpbrushlistP.h
|
||||
* app/gimpbrushpipe.[ch]
|
||||
* app/gimpbrushpipeP.h: did a brushes code-review: indentation,
|
||||
removed some includes, didn't find a bug :-)
|
||||
|
||||
* app/gradient.c
|
||||
* app/palette.c: we were leaking all gradient and palette preview
|
||||
pixmaps as well as all lists of palette colors on each refresh.
|
||||
|
||||
* libgimp/gimpenv.c: updated documentation.
|
||||
|
||||
2000-02-24 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/tool_options.c: another leak: don't allocate the
|
||||
|
|
|
@ -39,7 +39,8 @@ static GimpBrush * gimp_brush_select_brush (PaintCore *paint_core);
|
|||
static gboolean gimp_brush_want_null_motion (PaintCore *paint_core);
|
||||
|
||||
static guint gimp_brush_signals[LAST_SIGNAL];
|
||||
static GimpObjectClass* parent_class;
|
||||
|
||||
static GimpObjectClass *parent_class;
|
||||
|
||||
static void
|
||||
gimp_brush_destroy (GtkObject *object)
|
||||
|
@ -53,7 +54,8 @@ gimp_brush_destroy (GtkObject *object)
|
|||
if (brush->mask)
|
||||
temp_buf_free (brush->mask);
|
||||
|
||||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
||||
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -62,13 +64,13 @@ gimp_brush_class_init (GimpBrushClass *klass)
|
|||
GtkObjectClass *object_class;
|
||||
GtkType type;
|
||||
|
||||
object_class = GTK_OBJECT_CLASS(klass);
|
||||
object_class = GTK_OBJECT_CLASS (klass);
|
||||
|
||||
parent_class = gtk_type_class (gimp_object_get_type ());
|
||||
|
||||
type=object_class->type;
|
||||
type = object_class->type;
|
||||
|
||||
object_class->destroy = gimp_brush_destroy;
|
||||
object_class->destroy = gimp_brush_destroy;
|
||||
|
||||
klass->select_brush = gimp_brush_select_brush;
|
||||
klass->want_null_motion = gimp_brush_want_null_motion;
|
||||
|
@ -122,7 +124,7 @@ gimp_brush_get_type (void)
|
|||
GimpBrush *
|
||||
gimp_brush_new (gchar *filename)
|
||||
{
|
||||
GimpBrush *brush = GIMP_BRUSH (gtk_type_new (gimp_brush_get_type ()));
|
||||
GimpBrush *brush = GIMP_BRUSH (gtk_type_new (gimp_brush_get_type ()));
|
||||
|
||||
gimp_brush_load (brush, filename);
|
||||
|
||||
|
@ -149,7 +151,7 @@ gimp_brush_get_mask (GimpBrush *brush)
|
|||
return brush->mask;
|
||||
}
|
||||
|
||||
char *
|
||||
gchar *
|
||||
gimp_brush_get_name (GimpBrush *brush)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_BRUSH (brush), NULL);
|
||||
|
@ -206,7 +208,7 @@ gimp_brush_load (GimpBrush *brush,
|
|||
return;
|
||||
}
|
||||
|
||||
gimp_brush_load_brush(brush,fp,filename);
|
||||
gimp_brush_load_brush (brush, fp, filename);
|
||||
|
||||
/* Clean up */
|
||||
fclose (fp);
|
||||
|
@ -216,7 +218,6 @@ gimp_brush_load (GimpBrush *brush,
|
|||
temp_buf_swap (brush->mask);
|
||||
}
|
||||
|
||||
|
||||
gint
|
||||
gimp_brush_load_brush (GimpBrush *brush,
|
||||
FILE *fp,
|
||||
|
@ -304,4 +305,3 @@ gimp_brush_load_brush (GimpBrush *brush,
|
|||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,8 @@ static GimpBrush * gimp_brush_select_brush (PaintCore *paint_core);
|
|||
static gboolean gimp_brush_want_null_motion (PaintCore *paint_core);
|
||||
|
||||
static guint gimp_brush_signals[LAST_SIGNAL];
|
||||
static GimpObjectClass* parent_class;
|
||||
|
||||
static GimpObjectClass *parent_class;
|
||||
|
||||
static void
|
||||
gimp_brush_destroy (GtkObject *object)
|
||||
|
@ -53,7 +54,8 @@ gimp_brush_destroy (GtkObject *object)
|
|||
if (brush->mask)
|
||||
temp_buf_free (brush->mask);
|
||||
|
||||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
||||
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -62,13 +64,13 @@ gimp_brush_class_init (GimpBrushClass *klass)
|
|||
GtkObjectClass *object_class;
|
||||
GtkType type;
|
||||
|
||||
object_class = GTK_OBJECT_CLASS(klass);
|
||||
object_class = GTK_OBJECT_CLASS (klass);
|
||||
|
||||
parent_class = gtk_type_class (gimp_object_get_type ());
|
||||
|
||||
type=object_class->type;
|
||||
type = object_class->type;
|
||||
|
||||
object_class->destroy = gimp_brush_destroy;
|
||||
object_class->destroy = gimp_brush_destroy;
|
||||
|
||||
klass->select_brush = gimp_brush_select_brush;
|
||||
klass->want_null_motion = gimp_brush_want_null_motion;
|
||||
|
@ -122,7 +124,7 @@ gimp_brush_get_type (void)
|
|||
GimpBrush *
|
||||
gimp_brush_new (gchar *filename)
|
||||
{
|
||||
GimpBrush *brush = GIMP_BRUSH (gtk_type_new (gimp_brush_get_type ()));
|
||||
GimpBrush *brush = GIMP_BRUSH (gtk_type_new (gimp_brush_get_type ()));
|
||||
|
||||
gimp_brush_load (brush, filename);
|
||||
|
||||
|
@ -149,7 +151,7 @@ gimp_brush_get_mask (GimpBrush *brush)
|
|||
return brush->mask;
|
||||
}
|
||||
|
||||
char *
|
||||
gchar *
|
||||
gimp_brush_get_name (GimpBrush *brush)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_BRUSH (brush), NULL);
|
||||
|
@ -206,7 +208,7 @@ gimp_brush_load (GimpBrush *brush,
|
|||
return;
|
||||
}
|
||||
|
||||
gimp_brush_load_brush(brush,fp,filename);
|
||||
gimp_brush_load_brush (brush, fp, filename);
|
||||
|
||||
/* Clean up */
|
||||
fclose (fp);
|
||||
|
@ -216,7 +218,6 @@ gimp_brush_load (GimpBrush *brush,
|
|||
temp_buf_swap (brush->mask);
|
||||
}
|
||||
|
||||
|
||||
gint
|
||||
gimp_brush_load_brush (GimpBrush *brush,
|
||||
FILE *fp,
|
||||
|
@ -304,4 +305,3 @@ gimp_brush_load_brush (GimpBrush *brush,
|
|||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
struct _GimpBrush
|
||||
{
|
||||
GimpObject gobject;
|
||||
GimpObject gobject;
|
||||
|
||||
gchar *filename; /* actual filename--brush's location on disk */
|
||||
gchar *name; /* brush's name--for brush selection dialog */
|
||||
|
@ -43,33 +43,31 @@ struct _GimpBrushClass
|
|||
{
|
||||
GimpObjectClass parent_class;
|
||||
|
||||
GimpBrush * (* select_brush) (PaintCore *);
|
||||
gboolean (* want_null_motion) (PaintCore *);
|
||||
GimpBrush * (* select_brush) (PaintCore *paint_core);
|
||||
gboolean (* want_null_motion) (PaintCore *paint_core);
|
||||
};
|
||||
|
||||
#define GIMP_BRUSH_CLASS(klass) \
|
||||
GTK_CHECK_CLASS_CAST (klass, gimp_brush_get_type(), GimpBrushClass)
|
||||
|
||||
#define GIMP_TYPE_BRUSH (gimp_brush_get_type ())
|
||||
#define GIMP_BRUSH(obj) (GIMP_CHECK_CAST ((obj), GIMP_TYPE_BRUSH, GimpBrush))
|
||||
#define GIMP_IS_BRUSH(obj) (GIMP_CHECK_TYPE ((obj), GIMP_TYPE_BRUSH))
|
||||
#define GIMP_BRUSH_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gimp_brush_get_type(), GimpBrushClass)
|
||||
#define GIMP_TYPE_BRUSH (gimp_brush_get_type ())
|
||||
#define GIMP_BRUSH(obj) (GIMP_CHECK_CAST ((obj), GIMP_TYPE_BRUSH, GimpBrush))
|
||||
#define GIMP_IS_BRUSH(obj) (GIMP_CHECK_TYPE ((obj), GIMP_TYPE_BRUSH))
|
||||
|
||||
GtkType gimp_brush_get_type (void);
|
||||
GimpBrush * gimp_brush_new (gchar *filename);
|
||||
|
||||
void gimp_brush_load (GimpBrush *brush,
|
||||
gchar *filename);
|
||||
int gimp_brush_load_brush (GimpBrush *brush,
|
||||
gint gimp_brush_load_brush (GimpBrush *brush,
|
||||
FILE *fp,
|
||||
gchar *filename);
|
||||
|
||||
TempBuf * gimp_brush_get_mask (GimpBrush *brush);
|
||||
|
||||
char * gimp_brush_get_name (GimpBrush *brush);
|
||||
gchar * gimp_brush_get_name (GimpBrush *brush);
|
||||
void gimp_brush_set_name (GimpBrush *brush,
|
||||
gchar *name);
|
||||
|
||||
int gimp_brush_get_spacing (GimpBrush *brush);
|
||||
gint gimp_brush_get_spacing (GimpBrush *brush);
|
||||
void gimp_brush_set_spacing (GimpBrush *brush,
|
||||
gint spacing);
|
||||
|
||||
|
|
|
@ -38,33 +38,34 @@
|
|||
|
||||
static void gimp_brush_generated_generate (GimpBrushGenerated *brush);
|
||||
|
||||
static GimpObjectClass* parent_class;
|
||||
static GimpObjectClass *parent_class;
|
||||
|
||||
static void
|
||||
gimp_brush_generated_destroy (GtkObject *object)
|
||||
{
|
||||
GTK_OBJECT_CLASS(parent_class)->destroy (object);
|
||||
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
||||
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_brush_generated_class_init (GimpBrushGeneratedClass *klass)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
|
||||
|
||||
object_class = GTK_OBJECT_CLASS (klass);
|
||||
|
||||
parent_class = gtk_type_class (GIMP_TYPE_BRUSH);
|
||||
object_class->destroy = gimp_brush_generated_destroy;
|
||||
object_class->destroy = gimp_brush_generated_destroy;
|
||||
}
|
||||
|
||||
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;
|
||||
brush->radius = 5.0;
|
||||
brush->hardness = 0.0;
|
||||
brush->angle = 0.0;
|
||||
brush->aspect_ratio = 1.0;
|
||||
brush->freeze = 0;
|
||||
}
|
||||
|
||||
guint
|
||||
|
@ -86,7 +87,7 @@ gimp_brush_generated_get_type (void)
|
|||
(GtkClassInitFunc) NULL
|
||||
};
|
||||
|
||||
type = gtk_type_unique(GIMP_TYPE_BRUSH, &info);
|
||||
type = gtk_type_unique (GIMP_TYPE_BRUSH, &info);
|
||||
}
|
||||
|
||||
return type;
|
||||
|
@ -123,12 +124,12 @@ GimpBrushGenerated *
|
|||
gimp_brush_generated_load (const gchar *file_name)
|
||||
{
|
||||
GimpBrushGenerated *brush;
|
||||
FILE *fp;
|
||||
gchar string[256];
|
||||
gfloat fl;
|
||||
gfloat version;
|
||||
FILE *fp;
|
||||
gchar string[256];
|
||||
gfloat fl;
|
||||
gfloat version;
|
||||
|
||||
if ((fp = fopen(file_name, "rb")) == NULL)
|
||||
if ((fp = fopen (file_name, "rb")) == NULL)
|
||||
return NULL;
|
||||
|
||||
/* make sure the file we are reading is the right type */
|
||||
|
@ -191,7 +192,7 @@ gimp_brush_generated_save (GimpBrushGenerated *brush,
|
|||
|
||||
if ((fp = fopen (file_name, "wb")) == NULL)
|
||||
{
|
||||
g_warning("Unable to save file %s", file_name);
|
||||
g_warning ("Unable to save file %s", file_name);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -260,28 +261,29 @@ gauss (gdouble f)
|
|||
if (f < -.5)
|
||||
{
|
||||
f = -1.0-f;
|
||||
return (2.0*f*f);
|
||||
return (2.0 * f*f);
|
||||
}
|
||||
if (f < .5)
|
||||
return (1.0-2.0*f*f);
|
||||
return (1.0 - 2.0 * f*f);
|
||||
f = 1.0 -f;
|
||||
return (2.0*f*f);
|
||||
return (2.0 * f*f);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_brush_generated_generate (GimpBrushGenerated *brush)
|
||||
{
|
||||
register GimpBrush *gbrush = NULL;
|
||||
register int x, y;
|
||||
register gint x, y;
|
||||
register guchar *centerp;
|
||||
register double d;
|
||||
register double exponent;
|
||||
register gdouble d;
|
||||
register gdouble exponent;
|
||||
register guchar a;
|
||||
register int length;
|
||||
register gint length;
|
||||
register guchar *lookup;
|
||||
double buffer[OVERSAMPLING];
|
||||
register double sum, c, s, tx, ty;
|
||||
int width, height;
|
||||
gdouble buffer[OVERSAMPLING];
|
||||
register gdouble sum, c, s, tx, ty;
|
||||
gint width, height;
|
||||
|
||||
g_return_if_fail (brush != NULL);
|
||||
g_return_if_fail (GIMP_IS_BRUSH_GENERATED (brush));
|
||||
|
||||
|
@ -352,9 +354,9 @@ gimp_brush_generated_generate (GimpBrushGenerated *brush)
|
|||
buffer[x%OVERSAMPLING] = 0.0;
|
||||
else
|
||||
/* buffer[x%OVERSAMPLING] = (1.0 - pow (d/brush->radius, exponent)); */
|
||||
buffer[x%OVERSAMPLING] = gauss (pow (d/brush->radius, exponent));
|
||||
buffer[x%OVERSAMPLING] = gauss (pow (d/brush->radius, exponent));
|
||||
sum += buffer[x%OVERSAMPLING];
|
||||
lookup[x++] = RINT (sum*(255.0/OVERSAMPLING));
|
||||
lookup[x++] = RINT (sum*(255.0/OVERSAMPLING));
|
||||
}
|
||||
while (x < length)
|
||||
{
|
||||
|
@ -389,7 +391,7 @@ gimp_brush_generated_set_radius (GimpBrushGenerated *brush,
|
|||
|
||||
if (radius < 0.0)
|
||||
radius = 0.0;
|
||||
else if(radius > 32767.0)
|
||||
else if (radius > 32767.0)
|
||||
radius = 32767.0;
|
||||
if (radius == brush->radius)
|
||||
return radius;
|
||||
|
|
|
@ -38,33 +38,34 @@
|
|||
|
||||
static void gimp_brush_generated_generate (GimpBrushGenerated *brush);
|
||||
|
||||
static GimpObjectClass* parent_class;
|
||||
static GimpObjectClass *parent_class;
|
||||
|
||||
static void
|
||||
gimp_brush_generated_destroy (GtkObject *object)
|
||||
{
|
||||
GTK_OBJECT_CLASS(parent_class)->destroy (object);
|
||||
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
||||
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_brush_generated_class_init (GimpBrushGeneratedClass *klass)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
|
||||
|
||||
object_class = GTK_OBJECT_CLASS (klass);
|
||||
|
||||
parent_class = gtk_type_class (GIMP_TYPE_BRUSH);
|
||||
object_class->destroy = gimp_brush_generated_destroy;
|
||||
object_class->destroy = gimp_brush_generated_destroy;
|
||||
}
|
||||
|
||||
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;
|
||||
brush->radius = 5.0;
|
||||
brush->hardness = 0.0;
|
||||
brush->angle = 0.0;
|
||||
brush->aspect_ratio = 1.0;
|
||||
brush->freeze = 0;
|
||||
}
|
||||
|
||||
guint
|
||||
|
@ -86,7 +87,7 @@ gimp_brush_generated_get_type (void)
|
|||
(GtkClassInitFunc) NULL
|
||||
};
|
||||
|
||||
type = gtk_type_unique(GIMP_TYPE_BRUSH, &info);
|
||||
type = gtk_type_unique (GIMP_TYPE_BRUSH, &info);
|
||||
}
|
||||
|
||||
return type;
|
||||
|
@ -123,12 +124,12 @@ GimpBrushGenerated *
|
|||
gimp_brush_generated_load (const gchar *file_name)
|
||||
{
|
||||
GimpBrushGenerated *brush;
|
||||
FILE *fp;
|
||||
gchar string[256];
|
||||
gfloat fl;
|
||||
gfloat version;
|
||||
FILE *fp;
|
||||
gchar string[256];
|
||||
gfloat fl;
|
||||
gfloat version;
|
||||
|
||||
if ((fp = fopen(file_name, "rb")) == NULL)
|
||||
if ((fp = fopen (file_name, "rb")) == NULL)
|
||||
return NULL;
|
||||
|
||||
/* make sure the file we are reading is the right type */
|
||||
|
@ -191,7 +192,7 @@ gimp_brush_generated_save (GimpBrushGenerated *brush,
|
|||
|
||||
if ((fp = fopen (file_name, "wb")) == NULL)
|
||||
{
|
||||
g_warning("Unable to save file %s", file_name);
|
||||
g_warning ("Unable to save file %s", file_name);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -260,28 +261,29 @@ gauss (gdouble f)
|
|||
if (f < -.5)
|
||||
{
|
||||
f = -1.0-f;
|
||||
return (2.0*f*f);
|
||||
return (2.0 * f*f);
|
||||
}
|
||||
if (f < .5)
|
||||
return (1.0-2.0*f*f);
|
||||
return (1.0 - 2.0 * f*f);
|
||||
f = 1.0 -f;
|
||||
return (2.0*f*f);
|
||||
return (2.0 * f*f);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_brush_generated_generate (GimpBrushGenerated *brush)
|
||||
{
|
||||
register GimpBrush *gbrush = NULL;
|
||||
register int x, y;
|
||||
register gint x, y;
|
||||
register guchar *centerp;
|
||||
register double d;
|
||||
register double exponent;
|
||||
register gdouble d;
|
||||
register gdouble exponent;
|
||||
register guchar a;
|
||||
register int length;
|
||||
register gint length;
|
||||
register guchar *lookup;
|
||||
double buffer[OVERSAMPLING];
|
||||
register double sum, c, s, tx, ty;
|
||||
int width, height;
|
||||
gdouble buffer[OVERSAMPLING];
|
||||
register gdouble sum, c, s, tx, ty;
|
||||
gint width, height;
|
||||
|
||||
g_return_if_fail (brush != NULL);
|
||||
g_return_if_fail (GIMP_IS_BRUSH_GENERATED (brush));
|
||||
|
||||
|
@ -352,9 +354,9 @@ gimp_brush_generated_generate (GimpBrushGenerated *brush)
|
|||
buffer[x%OVERSAMPLING] = 0.0;
|
||||
else
|
||||
/* buffer[x%OVERSAMPLING] = (1.0 - pow (d/brush->radius, exponent)); */
|
||||
buffer[x%OVERSAMPLING] = gauss (pow (d/brush->radius, exponent));
|
||||
buffer[x%OVERSAMPLING] = gauss (pow (d/brush->radius, exponent));
|
||||
sum += buffer[x%OVERSAMPLING];
|
||||
lookup[x++] = RINT (sum*(255.0/OVERSAMPLING));
|
||||
lookup[x++] = RINT (sum*(255.0/OVERSAMPLING));
|
||||
}
|
||||
while (x < length)
|
||||
{
|
||||
|
@ -389,7 +391,7 @@ gimp_brush_generated_set_radius (GimpBrushGenerated *brush,
|
|||
|
||||
if (radius < 0.0)
|
||||
radius = 0.0;
|
||||
else if(radius > 32767.0)
|
||||
else if (radius > 32767.0)
|
||||
radius = 32767.0;
|
||||
if (radius == brush->radius)
|
||||
return radius;
|
||||
|
|
|
@ -38,33 +38,34 @@
|
|||
|
||||
static void gimp_brush_generated_generate (GimpBrushGenerated *brush);
|
||||
|
||||
static GimpObjectClass* parent_class;
|
||||
static GimpObjectClass *parent_class;
|
||||
|
||||
static void
|
||||
gimp_brush_generated_destroy (GtkObject *object)
|
||||
{
|
||||
GTK_OBJECT_CLASS(parent_class)->destroy (object);
|
||||
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
||||
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_brush_generated_class_init (GimpBrushGeneratedClass *klass)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
|
||||
|
||||
object_class = GTK_OBJECT_CLASS (klass);
|
||||
|
||||
parent_class = gtk_type_class (GIMP_TYPE_BRUSH);
|
||||
object_class->destroy = gimp_brush_generated_destroy;
|
||||
object_class->destroy = gimp_brush_generated_destroy;
|
||||
}
|
||||
|
||||
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;
|
||||
brush->radius = 5.0;
|
||||
brush->hardness = 0.0;
|
||||
brush->angle = 0.0;
|
||||
brush->aspect_ratio = 1.0;
|
||||
brush->freeze = 0;
|
||||
}
|
||||
|
||||
guint
|
||||
|
@ -86,7 +87,7 @@ gimp_brush_generated_get_type (void)
|
|||
(GtkClassInitFunc) NULL
|
||||
};
|
||||
|
||||
type = gtk_type_unique(GIMP_TYPE_BRUSH, &info);
|
||||
type = gtk_type_unique (GIMP_TYPE_BRUSH, &info);
|
||||
}
|
||||
|
||||
return type;
|
||||
|
@ -123,12 +124,12 @@ GimpBrushGenerated *
|
|||
gimp_brush_generated_load (const gchar *file_name)
|
||||
{
|
||||
GimpBrushGenerated *brush;
|
||||
FILE *fp;
|
||||
gchar string[256];
|
||||
gfloat fl;
|
||||
gfloat version;
|
||||
FILE *fp;
|
||||
gchar string[256];
|
||||
gfloat fl;
|
||||
gfloat version;
|
||||
|
||||
if ((fp = fopen(file_name, "rb")) == NULL)
|
||||
if ((fp = fopen (file_name, "rb")) == NULL)
|
||||
return NULL;
|
||||
|
||||
/* make sure the file we are reading is the right type */
|
||||
|
@ -191,7 +192,7 @@ gimp_brush_generated_save (GimpBrushGenerated *brush,
|
|||
|
||||
if ((fp = fopen (file_name, "wb")) == NULL)
|
||||
{
|
||||
g_warning("Unable to save file %s", file_name);
|
||||
g_warning ("Unable to save file %s", file_name);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -260,28 +261,29 @@ gauss (gdouble f)
|
|||
if (f < -.5)
|
||||
{
|
||||
f = -1.0-f;
|
||||
return (2.0*f*f);
|
||||
return (2.0 * f*f);
|
||||
}
|
||||
if (f < .5)
|
||||
return (1.0-2.0*f*f);
|
||||
return (1.0 - 2.0 * f*f);
|
||||
f = 1.0 -f;
|
||||
return (2.0*f*f);
|
||||
return (2.0 * f*f);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_brush_generated_generate (GimpBrushGenerated *brush)
|
||||
{
|
||||
register GimpBrush *gbrush = NULL;
|
||||
register int x, y;
|
||||
register gint x, y;
|
||||
register guchar *centerp;
|
||||
register double d;
|
||||
register double exponent;
|
||||
register gdouble d;
|
||||
register gdouble exponent;
|
||||
register guchar a;
|
||||
register int length;
|
||||
register gint length;
|
||||
register guchar *lookup;
|
||||
double buffer[OVERSAMPLING];
|
||||
register double sum, c, s, tx, ty;
|
||||
int width, height;
|
||||
gdouble buffer[OVERSAMPLING];
|
||||
register gdouble sum, c, s, tx, ty;
|
||||
gint width, height;
|
||||
|
||||
g_return_if_fail (brush != NULL);
|
||||
g_return_if_fail (GIMP_IS_BRUSH_GENERATED (brush));
|
||||
|
||||
|
@ -352,9 +354,9 @@ gimp_brush_generated_generate (GimpBrushGenerated *brush)
|
|||
buffer[x%OVERSAMPLING] = 0.0;
|
||||
else
|
||||
/* buffer[x%OVERSAMPLING] = (1.0 - pow (d/brush->radius, exponent)); */
|
||||
buffer[x%OVERSAMPLING] = gauss (pow (d/brush->radius, exponent));
|
||||
buffer[x%OVERSAMPLING] = gauss (pow (d/brush->radius, exponent));
|
||||
sum += buffer[x%OVERSAMPLING];
|
||||
lookup[x++] = RINT (sum*(255.0/OVERSAMPLING));
|
||||
lookup[x++] = RINT (sum*(255.0/OVERSAMPLING));
|
||||
}
|
||||
while (x < length)
|
||||
{
|
||||
|
@ -389,7 +391,7 @@ gimp_brush_generated_set_radius (GimpBrushGenerated *brush,
|
|||
|
||||
if (radius < 0.0)
|
||||
radius = 0.0;
|
||||
else if(radius > 32767.0)
|
||||
else if (radius > 32767.0)
|
||||
radius = 32767.0;
|
||||
if (radius == brush->radius)
|
||||
return radius;
|
||||
|
|
|
@ -26,10 +26,10 @@ typedef struct _GimpBrushGenerated
|
|||
{
|
||||
GimpBrush gbrush;
|
||||
|
||||
gfloat radius;
|
||||
gfloat hardness; /* 0.0 - 1.0 */
|
||||
gfloat angle; /* in degrees */
|
||||
gfloat aspect_ratio; /* y/x */
|
||||
gfloat radius;
|
||||
gfloat hardness; /* 0.0 - 1.0 */
|
||||
gfloat angle; /* in degrees */
|
||||
gfloat aspect_ratio; /* y/x */
|
||||
|
||||
gint freeze;
|
||||
|
||||
|
@ -39,7 +39,7 @@ typedef struct _GimpBrushGenerated
|
|||
typedef struct _GimpBrushGeneratedClass
|
||||
{
|
||||
GimpBrushClass parent_class;
|
||||
|
||||
|
||||
void (* generate) (GimpBrushGenerated *brush);
|
||||
} GimpBrushGeneratedClass;
|
||||
|
||||
|
|
|
@ -35,10 +35,11 @@
|
|||
#include "paint_core.h"
|
||||
#include "gimprc.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
#include "libgimp/gimpmath.h"
|
||||
#include "libgimp/parasiteio.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
static GimpBrushClass *gimp_brush_class;
|
||||
static GimpBrushPixmapClass *gimp_brush_pixmap_class;
|
||||
|
||||
|
@ -80,7 +81,7 @@ void
|
|||
gimp_brush_pixmap_init (GimpBrushPixmap *brush)
|
||||
{
|
||||
brush->pixmap_mask = NULL;
|
||||
brush->pipe = NULL;
|
||||
brush->pipe = NULL;
|
||||
}
|
||||
|
||||
GtkType
|
||||
|
@ -137,10 +138,10 @@ gimp_brush_pixmap_select_brush (PaintCore *paint_core)
|
|||
angle += G_PI_2;
|
||||
/* Map it to the [0..2*G_PI) interval */
|
||||
if (angle < 0)
|
||||
angle += 2.*G_PI;
|
||||
else if (angle > 2.*G_PI)
|
||||
angle -= 2.*G_PI;
|
||||
ix = RINT (angle / (2.*G_PI) * pipe->rank[i]);
|
||||
angle += 2.0 * G_PI;
|
||||
else if (angle > 2.0 * G_PI)
|
||||
angle -= 2.0 * G_PI;
|
||||
ix = RINT (angle / (2.0 * G_PI) * pipe->rank[i]);
|
||||
break;
|
||||
case PIPE_SELECT_RANDOM:
|
||||
/* This probably isn't the right way */
|
||||
|
@ -177,7 +178,7 @@ static gboolean
|
|||
gimp_brush_pixmap_want_null_motion (PaintCore *paint_core)
|
||||
{
|
||||
GimpBrushPipe *pipe;
|
||||
int i;
|
||||
gint i;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_BRUSH_PIXMAP (paint_core->brush), TRUE);
|
||||
|
||||
|
|
|
@ -35,10 +35,11 @@
|
|||
#include "paint_core.h"
|
||||
#include "gimprc.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
#include "libgimp/gimpmath.h"
|
||||
#include "libgimp/parasiteio.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
static GimpBrushClass *gimp_brush_class;
|
||||
static GimpBrushPixmapClass *gimp_brush_pixmap_class;
|
||||
|
||||
|
@ -80,7 +81,7 @@ void
|
|||
gimp_brush_pixmap_init (GimpBrushPixmap *brush)
|
||||
{
|
||||
brush->pixmap_mask = NULL;
|
||||
brush->pipe = NULL;
|
||||
brush->pipe = NULL;
|
||||
}
|
||||
|
||||
GtkType
|
||||
|
@ -137,10 +138,10 @@ gimp_brush_pixmap_select_brush (PaintCore *paint_core)
|
|||
angle += G_PI_2;
|
||||
/* Map it to the [0..2*G_PI) interval */
|
||||
if (angle < 0)
|
||||
angle += 2.*G_PI;
|
||||
else if (angle > 2.*G_PI)
|
||||
angle -= 2.*G_PI;
|
||||
ix = RINT (angle / (2.*G_PI) * pipe->rank[i]);
|
||||
angle += 2.0 * G_PI;
|
||||
else if (angle > 2.0 * G_PI)
|
||||
angle -= 2.0 * G_PI;
|
||||
ix = RINT (angle / (2.0 * G_PI) * pipe->rank[i]);
|
||||
break;
|
||||
case PIPE_SELECT_RANDOM:
|
||||
/* This probably isn't the right way */
|
||||
|
@ -177,7 +178,7 @@ static gboolean
|
|||
gimp_brush_pixmap_want_null_motion (PaintCore *paint_core)
|
||||
{
|
||||
GimpBrushPipe *pipe;
|
||||
int i;
|
||||
gint i;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_BRUSH_PIXMAP (paint_core->brush), TRUE);
|
||||
|
||||
|
|
|
@ -28,25 +28,26 @@
|
|||
typedef struct _GimpBrushPixmap GimpBrushPixmap;
|
||||
typedef struct _GimpBrushPipe GimpBrushPipe;
|
||||
|
||||
#define GIMP_TYPE_BRUSH_PIXMAP (gimp_brush_pixmap_get_type ())
|
||||
#define GIMP_BRUSH_PIXMAP(obj) (GIMP_CHECK_CAST ((obj), GIMP_TYPE_BRUSH_PIXMAP, GimpBrushPixmap))
|
||||
#define GIMP_TYPE_BRUSH_PIXMAP (gimp_brush_pixmap_get_type ())
|
||||
#define GIMP_BRUSH_PIXMAP(obj) (GIMP_CHECK_CAST ((obj), GIMP_TYPE_BRUSH_PIXMAP, GimpBrushPixmap))
|
||||
#define GIMP_IS_BRUSH_PIXMAP(obj) (GIMP_CHECK_TYPE ((obj), GIMP_TYPE_BRUSH_PIXMAP))
|
||||
|
||||
#define GIMP_TYPE_BRUSH_PIPE (gimp_brush_pipe_get_type ())
|
||||
#define GIMP_BRUSH_PIPE(obj) (GIMP_CHECK_CAST ((obj), GIMP_TYPE_BRUSH_PIPE, GimpBrushPipe))
|
||||
#define GIMP_TYPE_BRUSH_PIPE (gimp_brush_pipe_get_type ())
|
||||
#define GIMP_BRUSH_PIPE(obj) (GIMP_CHECK_CAST ((obj), GIMP_TYPE_BRUSH_PIPE, GimpBrushPipe))
|
||||
#define GIMP_IS_BRUSH_PIPE(obj) (GIMP_CHECK_TYPE ((obj), GIMP_TYPE_BRUSH_PIPE))
|
||||
|
||||
GtkType gimp_brush_pixmap_get_type (void);
|
||||
GtkType gimp_brush_pipe_get_type (void);
|
||||
GtkType gimp_brush_pixmap_get_type (void);
|
||||
GtkType gimp_brush_pipe_get_type (void);
|
||||
|
||||
GimpBrushPipe *gimp_brush_pipe_load (char *filename);
|
||||
GimpBrushPipe *gimp_brush_pixmap_load (char *filename);
|
||||
GimpBrushPipe * gimp_brush_pipe_load (gchar *filename);
|
||||
GimpBrushPipe * gimp_brush_pixmap_load (gchar *filename);
|
||||
|
||||
TempBuf *gimp_brush_pixmap_pixmap (GimpBrushPixmap *);
|
||||
TempBuf * gimp_brush_pixmap_pixmap (GimpBrushPixmap *brush);
|
||||
|
||||
/* appearantly GIMP_IS_BRUSH_PIPE () returning TRUE is no indication that you really
|
||||
have a brush_pipe in front of you, so here we introduce a macro that works: */
|
||||
/* appearantly GIMP_IS_BRUSH_PIPE () returning TRUE is no indication
|
||||
* that you really have a brush_pipe in front of you, so here we introduce
|
||||
* a macro that works:
|
||||
*/
|
||||
#define GIMP_IS_REALLY_A_BRUSH_PIPE(obj) (GIMP_IS_BRUSH_PIPE (obj) && GIMP_BRUSH_PIPE (obj)->nbrushes > 1)
|
||||
|
||||
|
||||
#endif /* __GIMPBRUSHPIPE_H__ */
|
||||
|
|
|
@ -39,7 +39,8 @@ static GimpBrush * gimp_brush_select_brush (PaintCore *paint_core);
|
|||
static gboolean gimp_brush_want_null_motion (PaintCore *paint_core);
|
||||
|
||||
static guint gimp_brush_signals[LAST_SIGNAL];
|
||||
static GimpObjectClass* parent_class;
|
||||
|
||||
static GimpObjectClass *parent_class;
|
||||
|
||||
static void
|
||||
gimp_brush_destroy (GtkObject *object)
|
||||
|
@ -53,7 +54,8 @@ gimp_brush_destroy (GtkObject *object)
|
|||
if (brush->mask)
|
||||
temp_buf_free (brush->mask);
|
||||
|
||||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
||||
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -62,13 +64,13 @@ gimp_brush_class_init (GimpBrushClass *klass)
|
|||
GtkObjectClass *object_class;
|
||||
GtkType type;
|
||||
|
||||
object_class = GTK_OBJECT_CLASS(klass);
|
||||
object_class = GTK_OBJECT_CLASS (klass);
|
||||
|
||||
parent_class = gtk_type_class (gimp_object_get_type ());
|
||||
|
||||
type=object_class->type;
|
||||
type = object_class->type;
|
||||
|
||||
object_class->destroy = gimp_brush_destroy;
|
||||
object_class->destroy = gimp_brush_destroy;
|
||||
|
||||
klass->select_brush = gimp_brush_select_brush;
|
||||
klass->want_null_motion = gimp_brush_want_null_motion;
|
||||
|
@ -122,7 +124,7 @@ gimp_brush_get_type (void)
|
|||
GimpBrush *
|
||||
gimp_brush_new (gchar *filename)
|
||||
{
|
||||
GimpBrush *brush = GIMP_BRUSH (gtk_type_new (gimp_brush_get_type ()));
|
||||
GimpBrush *brush = GIMP_BRUSH (gtk_type_new (gimp_brush_get_type ()));
|
||||
|
||||
gimp_brush_load (brush, filename);
|
||||
|
||||
|
@ -149,7 +151,7 @@ gimp_brush_get_mask (GimpBrush *brush)
|
|||
return brush->mask;
|
||||
}
|
||||
|
||||
char *
|
||||
gchar *
|
||||
gimp_brush_get_name (GimpBrush *brush)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_BRUSH (brush), NULL);
|
||||
|
@ -206,7 +208,7 @@ gimp_brush_load (GimpBrush *brush,
|
|||
return;
|
||||
}
|
||||
|
||||
gimp_brush_load_brush(brush,fp,filename);
|
||||
gimp_brush_load_brush (brush, fp, filename);
|
||||
|
||||
/* Clean up */
|
||||
fclose (fp);
|
||||
|
@ -216,7 +218,6 @@ gimp_brush_load (GimpBrush *brush,
|
|||
temp_buf_swap (brush->mask);
|
||||
}
|
||||
|
||||
|
||||
gint
|
||||
gimp_brush_load_brush (GimpBrush *brush,
|
||||
FILE *fp,
|
||||
|
@ -304,4 +305,3 @@ gimp_brush_load_brush (GimpBrush *brush,
|
|||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
struct _GimpBrush
|
||||
{
|
||||
GimpObject gobject;
|
||||
GimpObject gobject;
|
||||
|
||||
gchar *filename; /* actual filename--brush's location on disk */
|
||||
gchar *name; /* brush's name--for brush selection dialog */
|
||||
|
@ -43,33 +43,31 @@ struct _GimpBrushClass
|
|||
{
|
||||
GimpObjectClass parent_class;
|
||||
|
||||
GimpBrush * (* select_brush) (PaintCore *);
|
||||
gboolean (* want_null_motion) (PaintCore *);
|
||||
GimpBrush * (* select_brush) (PaintCore *paint_core);
|
||||
gboolean (* want_null_motion) (PaintCore *paint_core);
|
||||
};
|
||||
|
||||
#define GIMP_BRUSH_CLASS(klass) \
|
||||
GTK_CHECK_CLASS_CAST (klass, gimp_brush_get_type(), GimpBrushClass)
|
||||
|
||||
#define GIMP_TYPE_BRUSH (gimp_brush_get_type ())
|
||||
#define GIMP_BRUSH(obj) (GIMP_CHECK_CAST ((obj), GIMP_TYPE_BRUSH, GimpBrush))
|
||||
#define GIMP_IS_BRUSH(obj) (GIMP_CHECK_TYPE ((obj), GIMP_TYPE_BRUSH))
|
||||
#define GIMP_BRUSH_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gimp_brush_get_type(), GimpBrushClass)
|
||||
#define GIMP_TYPE_BRUSH (gimp_brush_get_type ())
|
||||
#define GIMP_BRUSH(obj) (GIMP_CHECK_CAST ((obj), GIMP_TYPE_BRUSH, GimpBrush))
|
||||
#define GIMP_IS_BRUSH(obj) (GIMP_CHECK_TYPE ((obj), GIMP_TYPE_BRUSH))
|
||||
|
||||
GtkType gimp_brush_get_type (void);
|
||||
GimpBrush * gimp_brush_new (gchar *filename);
|
||||
|
||||
void gimp_brush_load (GimpBrush *brush,
|
||||
gchar *filename);
|
||||
int gimp_brush_load_brush (GimpBrush *brush,
|
||||
gint gimp_brush_load_brush (GimpBrush *brush,
|
||||
FILE *fp,
|
||||
gchar *filename);
|
||||
|
||||
TempBuf * gimp_brush_get_mask (GimpBrush *brush);
|
||||
|
||||
char * gimp_brush_get_name (GimpBrush *brush);
|
||||
gchar * gimp_brush_get_name (GimpBrush *brush);
|
||||
void gimp_brush_set_name (GimpBrush *brush,
|
||||
gchar *name);
|
||||
|
||||
int gimp_brush_get_spacing (GimpBrush *brush);
|
||||
gint gimp_brush_get_spacing (GimpBrush *brush);
|
||||
void gimp_brush_set_spacing (GimpBrush *brush,
|
||||
gint spacing);
|
||||
|
||||
|
|
|
@ -38,33 +38,34 @@
|
|||
|
||||
static void gimp_brush_generated_generate (GimpBrushGenerated *brush);
|
||||
|
||||
static GimpObjectClass* parent_class;
|
||||
static GimpObjectClass *parent_class;
|
||||
|
||||
static void
|
||||
gimp_brush_generated_destroy (GtkObject *object)
|
||||
{
|
||||
GTK_OBJECT_CLASS(parent_class)->destroy (object);
|
||||
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
||||
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_brush_generated_class_init (GimpBrushGeneratedClass *klass)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
|
||||
|
||||
object_class = GTK_OBJECT_CLASS (klass);
|
||||
|
||||
parent_class = gtk_type_class (GIMP_TYPE_BRUSH);
|
||||
object_class->destroy = gimp_brush_generated_destroy;
|
||||
object_class->destroy = gimp_brush_generated_destroy;
|
||||
}
|
||||
|
||||
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;
|
||||
brush->radius = 5.0;
|
||||
brush->hardness = 0.0;
|
||||
brush->angle = 0.0;
|
||||
brush->aspect_ratio = 1.0;
|
||||
brush->freeze = 0;
|
||||
}
|
||||
|
||||
guint
|
||||
|
@ -86,7 +87,7 @@ gimp_brush_generated_get_type (void)
|
|||
(GtkClassInitFunc) NULL
|
||||
};
|
||||
|
||||
type = gtk_type_unique(GIMP_TYPE_BRUSH, &info);
|
||||
type = gtk_type_unique (GIMP_TYPE_BRUSH, &info);
|
||||
}
|
||||
|
||||
return type;
|
||||
|
@ -123,12 +124,12 @@ GimpBrushGenerated *
|
|||
gimp_brush_generated_load (const gchar *file_name)
|
||||
{
|
||||
GimpBrushGenerated *brush;
|
||||
FILE *fp;
|
||||
gchar string[256];
|
||||
gfloat fl;
|
||||
gfloat version;
|
||||
FILE *fp;
|
||||
gchar string[256];
|
||||
gfloat fl;
|
||||
gfloat version;
|
||||
|
||||
if ((fp = fopen(file_name, "rb")) == NULL)
|
||||
if ((fp = fopen (file_name, "rb")) == NULL)
|
||||
return NULL;
|
||||
|
||||
/* make sure the file we are reading is the right type */
|
||||
|
@ -191,7 +192,7 @@ gimp_brush_generated_save (GimpBrushGenerated *brush,
|
|||
|
||||
if ((fp = fopen (file_name, "wb")) == NULL)
|
||||
{
|
||||
g_warning("Unable to save file %s", file_name);
|
||||
g_warning ("Unable to save file %s", file_name);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -260,28 +261,29 @@ gauss (gdouble f)
|
|||
if (f < -.5)
|
||||
{
|
||||
f = -1.0-f;
|
||||
return (2.0*f*f);
|
||||
return (2.0 * f*f);
|
||||
}
|
||||
if (f < .5)
|
||||
return (1.0-2.0*f*f);
|
||||
return (1.0 - 2.0 * f*f);
|
||||
f = 1.0 -f;
|
||||
return (2.0*f*f);
|
||||
return (2.0 * f*f);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_brush_generated_generate (GimpBrushGenerated *brush)
|
||||
{
|
||||
register GimpBrush *gbrush = NULL;
|
||||
register int x, y;
|
||||
register gint x, y;
|
||||
register guchar *centerp;
|
||||
register double d;
|
||||
register double exponent;
|
||||
register gdouble d;
|
||||
register gdouble exponent;
|
||||
register guchar a;
|
||||
register int length;
|
||||
register gint length;
|
||||
register guchar *lookup;
|
||||
double buffer[OVERSAMPLING];
|
||||
register double sum, c, s, tx, ty;
|
||||
int width, height;
|
||||
gdouble buffer[OVERSAMPLING];
|
||||
register gdouble sum, c, s, tx, ty;
|
||||
gint width, height;
|
||||
|
||||
g_return_if_fail (brush != NULL);
|
||||
g_return_if_fail (GIMP_IS_BRUSH_GENERATED (brush));
|
||||
|
||||
|
@ -352,9 +354,9 @@ gimp_brush_generated_generate (GimpBrushGenerated *brush)
|
|||
buffer[x%OVERSAMPLING] = 0.0;
|
||||
else
|
||||
/* buffer[x%OVERSAMPLING] = (1.0 - pow (d/brush->radius, exponent)); */
|
||||
buffer[x%OVERSAMPLING] = gauss (pow (d/brush->radius, exponent));
|
||||
buffer[x%OVERSAMPLING] = gauss (pow (d/brush->radius, exponent));
|
||||
sum += buffer[x%OVERSAMPLING];
|
||||
lookup[x++] = RINT (sum*(255.0/OVERSAMPLING));
|
||||
lookup[x++] = RINT (sum*(255.0/OVERSAMPLING));
|
||||
}
|
||||
while (x < length)
|
||||
{
|
||||
|
@ -389,7 +391,7 @@ gimp_brush_generated_set_radius (GimpBrushGenerated *brush,
|
|||
|
||||
if (radius < 0.0)
|
||||
radius = 0.0;
|
||||
else if(radius > 32767.0)
|
||||
else if (radius > 32767.0)
|
||||
radius = 32767.0;
|
||||
if (radius == brush->radius)
|
||||
return radius;
|
||||
|
|
|
@ -26,10 +26,10 @@ typedef struct _GimpBrushGenerated
|
|||
{
|
||||
GimpBrush gbrush;
|
||||
|
||||
gfloat radius;
|
||||
gfloat hardness; /* 0.0 - 1.0 */
|
||||
gfloat angle; /* in degrees */
|
||||
gfloat aspect_ratio; /* y/x */
|
||||
gfloat radius;
|
||||
gfloat hardness; /* 0.0 - 1.0 */
|
||||
gfloat angle; /* in degrees */
|
||||
gfloat aspect_ratio; /* y/x */
|
||||
|
||||
gint freeze;
|
||||
|
||||
|
@ -39,7 +39,7 @@ typedef struct _GimpBrushGenerated
|
|||
typedef struct _GimpBrushGeneratedClass
|
||||
{
|
||||
GimpBrushClass parent_class;
|
||||
|
||||
|
||||
void (* generate) (GimpBrushGenerated *brush);
|
||||
} GimpBrushGeneratedClass;
|
||||
|
||||
|
|
|
@ -42,14 +42,13 @@
|
|||
#include "gimpbrush.h"
|
||||
#include "gimplistP.h"
|
||||
#include "gimpbrushlistP.h"
|
||||
#include "general.h"
|
||||
|
||||
#include "libgimp/gimpenv.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
/* global variables */
|
||||
GimpBrushList *brush_list = NULL;
|
||||
GimpBrushList *brush_list = NULL;
|
||||
|
||||
|
||||
/* local function prototypes */
|
||||
|
@ -65,7 +64,7 @@ static void
|
|||
gimp_brush_list_add_func (GimpList *list,
|
||||
gpointer val)
|
||||
{
|
||||
list->list=g_slist_insert_sorted (list->list, val, brush_compare_func);
|
||||
list->list = g_slist_insert_sorted (list->list, val, brush_compare_func);
|
||||
GIMP_BRUSH_LIST (list)->num_brushes++;
|
||||
}
|
||||
|
||||
|
@ -130,7 +129,7 @@ gimp_brush_list_new (void)
|
|||
|
||||
GIMP_LIST (list)->type = GIMP_TYPE_BRUSH;
|
||||
GIMP_LIST (list)->weak = FALSE;
|
||||
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
@ -290,9 +289,9 @@ brushes_free (void)
|
|||
gimp_brush_list_remove (brush_list, brush);
|
||||
}
|
||||
|
||||
g_free (vbr_dir);
|
||||
|
||||
brush_select_thaw_all ();
|
||||
|
||||
g_free (vbr_dir);
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
@ -333,28 +332,30 @@ gimp_brush_list_uniquefy_brush_name (GimpBrushList *brush_list,
|
|||
{
|
||||
GSList *list, *listb;
|
||||
GimpBrush *brushb;
|
||||
int number = 1;
|
||||
char *newname;
|
||||
char *oldname;
|
||||
char *ext;
|
||||
gint number = 1;
|
||||
gchar *newname;
|
||||
gchar *oldname;
|
||||
gchar *ext;
|
||||
|
||||
g_return_if_fail (GIMP_IS_BRUSH_LIST (brush_list));
|
||||
g_return_if_fail (GIMP_IS_BRUSH (brush));
|
||||
list = GIMP_LIST (brush_list)->list;
|
||||
while (list)
|
||||
|
||||
for (list = GIMP_LIST (brush_list)->list; list; list = g_slist_next (list))
|
||||
{
|
||||
brushb = GIMP_BRUSH (list->data);
|
||||
if (brush != brushb &&
|
||||
strcmp (gimp_brush_get_name (brush),
|
||||
gimp_brush_get_name (brushb)) == 0)
|
||||
{ /* names conflict */
|
||||
{
|
||||
/* names conflict */
|
||||
oldname = gimp_brush_get_name (brush);
|
||||
newname = g_malloc (strlen (oldname) + 10); /* if this aint enough
|
||||
yer screwed */
|
||||
strcpy (newname, oldname);
|
||||
if ((ext = strrchr(newname, '#')))
|
||||
if ((ext = strrchr (newname, '#')))
|
||||
{
|
||||
number = atoi (ext+1);
|
||||
if (&ext[(int)(log10 (number) + 1)] !=
|
||||
if (&ext[(gint)(log10 (number) + 1)] !=
|
||||
&newname[strlen (newname) - 1])
|
||||
{
|
||||
number = 1;
|
||||
|
@ -367,8 +368,7 @@ gimp_brush_list_uniquefy_brush_name (GimpBrushList *brush_list,
|
|||
ext = &newname[strlen (newname)];
|
||||
}
|
||||
sprintf (ext, "#%d", number+1);
|
||||
listb = GIMP_LIST (brush_list)->list;
|
||||
while (listb) /* make sure the new name is unique */
|
||||
for (listb = GIMP_LIST (brush_list)->list; listb; listb = listb->next)
|
||||
{
|
||||
brushb = GIMP_BRUSH (listb->data);
|
||||
if (brush != brushb &&
|
||||
|
@ -378,12 +378,12 @@ gimp_brush_list_uniquefy_brush_name (GimpBrushList *brush_list,
|
|||
sprintf (ext, "#%d", number+1);
|
||||
listb = GIMP_LIST (brush_list)->list;
|
||||
}
|
||||
listb = listb->next;
|
||||
}
|
||||
gimp_brush_set_name (brush, newname);
|
||||
g_free (newname);
|
||||
if (gimp_list_have (GIMP_LIST (brush_list), brush))
|
||||
{ /* ought to have a better way than this to resort the brush */
|
||||
{
|
||||
/* ought to have a better way than this to resort the brush */
|
||||
gtk_object_ref (GTK_OBJECT (brush));
|
||||
gimp_brush_list_remove (brush_list, brush);
|
||||
gimp_brush_list_add (brush_list, brush);
|
||||
|
@ -391,7 +391,6 @@ gimp_brush_list_uniquefy_brush_name (GimpBrushList *brush_list,
|
|||
}
|
||||
return;
|
||||
}
|
||||
list = list->next;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
|
||||
#include <glib.h>
|
||||
|
||||
#include "temp_buf.h"
|
||||
#include "gimpbrush.h"
|
||||
#include "gimpbrushlistF.h"
|
||||
|
||||
|
|
|
@ -7,17 +7,17 @@
|
|||
struct _GimpBrushList
|
||||
{
|
||||
GimpList gimplist;
|
||||
int num_brushes;
|
||||
|
||||
gint num_brushes;
|
||||
};
|
||||
|
||||
typedef struct _GimpBrushListClass GimpBrushListClass;
|
||||
|
||||
struct _GimpBrushListClass
|
||||
{
|
||||
GimpListClass parent_class;
|
||||
};
|
||||
|
||||
typedef struct _GimpBrushListClass GimpBrushListClass;
|
||||
|
||||
|
||||
#define BRUSH_LIST_CLASS(klass) \
|
||||
GTK_CHECK_CLASS_CAST (klass, gimp_brush_list_get_type(), GimpBrushListClass)
|
||||
|
||||
|
|
|
@ -35,10 +35,11 @@
|
|||
#include "paint_core.h"
|
||||
#include "gimprc.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
#include "libgimp/gimpmath.h"
|
||||
#include "libgimp/parasiteio.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
static GimpBrushClass *gimp_brush_class;
|
||||
static GimpBrushPixmapClass *gimp_brush_pixmap_class;
|
||||
|
||||
|
@ -80,7 +81,7 @@ void
|
|||
gimp_brush_pixmap_init (GimpBrushPixmap *brush)
|
||||
{
|
||||
brush->pixmap_mask = NULL;
|
||||
brush->pipe = NULL;
|
||||
brush->pipe = NULL;
|
||||
}
|
||||
|
||||
GtkType
|
||||
|
@ -137,10 +138,10 @@ gimp_brush_pixmap_select_brush (PaintCore *paint_core)
|
|||
angle += G_PI_2;
|
||||
/* Map it to the [0..2*G_PI) interval */
|
||||
if (angle < 0)
|
||||
angle += 2.*G_PI;
|
||||
else if (angle > 2.*G_PI)
|
||||
angle -= 2.*G_PI;
|
||||
ix = RINT (angle / (2.*G_PI) * pipe->rank[i]);
|
||||
angle += 2.0 * G_PI;
|
||||
else if (angle > 2.0 * G_PI)
|
||||
angle -= 2.0 * G_PI;
|
||||
ix = RINT (angle / (2.0 * G_PI) * pipe->rank[i]);
|
||||
break;
|
||||
case PIPE_SELECT_RANDOM:
|
||||
/* This probably isn't the right way */
|
||||
|
@ -177,7 +178,7 @@ static gboolean
|
|||
gimp_brush_pixmap_want_null_motion (PaintCore *paint_core)
|
||||
{
|
||||
GimpBrushPipe *pipe;
|
||||
int i;
|
||||
gint i;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_BRUSH_PIXMAP (paint_core->brush), TRUE);
|
||||
|
||||
|
|
|
@ -28,25 +28,26 @@
|
|||
typedef struct _GimpBrushPixmap GimpBrushPixmap;
|
||||
typedef struct _GimpBrushPipe GimpBrushPipe;
|
||||
|
||||
#define GIMP_TYPE_BRUSH_PIXMAP (gimp_brush_pixmap_get_type ())
|
||||
#define GIMP_BRUSH_PIXMAP(obj) (GIMP_CHECK_CAST ((obj), GIMP_TYPE_BRUSH_PIXMAP, GimpBrushPixmap))
|
||||
#define GIMP_TYPE_BRUSH_PIXMAP (gimp_brush_pixmap_get_type ())
|
||||
#define GIMP_BRUSH_PIXMAP(obj) (GIMP_CHECK_CAST ((obj), GIMP_TYPE_BRUSH_PIXMAP, GimpBrushPixmap))
|
||||
#define GIMP_IS_BRUSH_PIXMAP(obj) (GIMP_CHECK_TYPE ((obj), GIMP_TYPE_BRUSH_PIXMAP))
|
||||
|
||||
#define GIMP_TYPE_BRUSH_PIPE (gimp_brush_pipe_get_type ())
|
||||
#define GIMP_BRUSH_PIPE(obj) (GIMP_CHECK_CAST ((obj), GIMP_TYPE_BRUSH_PIPE, GimpBrushPipe))
|
||||
#define GIMP_TYPE_BRUSH_PIPE (gimp_brush_pipe_get_type ())
|
||||
#define GIMP_BRUSH_PIPE(obj) (GIMP_CHECK_CAST ((obj), GIMP_TYPE_BRUSH_PIPE, GimpBrushPipe))
|
||||
#define GIMP_IS_BRUSH_PIPE(obj) (GIMP_CHECK_TYPE ((obj), GIMP_TYPE_BRUSH_PIPE))
|
||||
|
||||
GtkType gimp_brush_pixmap_get_type (void);
|
||||
GtkType gimp_brush_pipe_get_type (void);
|
||||
GtkType gimp_brush_pixmap_get_type (void);
|
||||
GtkType gimp_brush_pipe_get_type (void);
|
||||
|
||||
GimpBrushPipe *gimp_brush_pipe_load (char *filename);
|
||||
GimpBrushPipe *gimp_brush_pixmap_load (char *filename);
|
||||
GimpBrushPipe * gimp_brush_pipe_load (gchar *filename);
|
||||
GimpBrushPipe * gimp_brush_pixmap_load (gchar *filename);
|
||||
|
||||
TempBuf *gimp_brush_pixmap_pixmap (GimpBrushPixmap *);
|
||||
TempBuf * gimp_brush_pixmap_pixmap (GimpBrushPixmap *brush);
|
||||
|
||||
/* appearantly GIMP_IS_BRUSH_PIPE () returning TRUE is no indication that you really
|
||||
have a brush_pipe in front of you, so here we introduce a macro that works: */
|
||||
/* appearantly GIMP_IS_BRUSH_PIPE () returning TRUE is no indication
|
||||
* that you really have a brush_pipe in front of you, so here we introduce
|
||||
* a macro that works:
|
||||
*/
|
||||
#define GIMP_IS_REALLY_A_BRUSH_PIPE(obj) (GIMP_IS_BRUSH_PIPE (obj) && GIMP_BRUSH_PIPE (obj)->nbrushes > 1)
|
||||
|
||||
|
||||
#endif /* __GIMPBRUSHPIPE_H__ */
|
||||
|
|
|
@ -40,6 +40,7 @@ typedef enum
|
|||
struct _GimpBrushPixmap
|
||||
{
|
||||
GimpBrush gbrush;
|
||||
|
||||
TempBuf *pixmap_mask;
|
||||
GimpBrushPipe *pipe;
|
||||
};
|
||||
|
@ -60,14 +61,18 @@ struct _GimpBrushPipe
|
|||
gint *index; /* Current index for incremental dimensions */
|
||||
};
|
||||
|
||||
typedef struct _GimpBrushPixmapClass
|
||||
typedef struct _GimpBrushPixmapClass GimpBrushPixmapClass;
|
||||
|
||||
struct _GimpBrushPixmapClass
|
||||
{
|
||||
GimpBrushClass parent_class;
|
||||
} GimpBrushPixmapClass;
|
||||
};
|
||||
|
||||
typedef struct _GimpBrushPipeClass
|
||||
typedef struct _GimpBrushPipeClass GimpBrushPipeClass;
|
||||
|
||||
struct _GimpBrushPipeClass
|
||||
{
|
||||
GimpBrushPixmapClass parent_class;
|
||||
} GimpBrushPipeClass;
|
||||
};
|
||||
|
||||
#endif /* __GIMPBRUSHPIPEP_H__ */
|
||||
|
|
|
@ -555,7 +555,7 @@ static guint n_gradient_targets = (sizeof (gradient_target_table) /
|
|||
/***** Public functions *****/
|
||||
|
||||
void
|
||||
gradients_init (int no_data)
|
||||
gradients_init (gint no_data)
|
||||
{
|
||||
if (gradients_list)
|
||||
gradients_free ();
|
||||
|
@ -5694,6 +5694,9 @@ grad_free_gradient (gradient_t *grad)
|
|||
if (grad->filename)
|
||||
g_free (grad->filename);
|
||||
|
||||
if (grad->pixmap)
|
||||
gdk_pixmap_unref (grad->pixmap);
|
||||
|
||||
g_free (grad);
|
||||
}
|
||||
|
||||
|
@ -5724,7 +5727,7 @@ static void
|
|||
grad_free_gradients (void)
|
||||
{
|
||||
grad_save_all (TRUE);
|
||||
|
||||
|
||||
g_slist_free (gradients_list);
|
||||
|
||||
num_gradients = 0;
|
||||
|
|
|
@ -555,7 +555,7 @@ static guint n_gradient_targets = (sizeof (gradient_target_table) /
|
|||
/***** Public functions *****/
|
||||
|
||||
void
|
||||
gradients_init (int no_data)
|
||||
gradients_init (gint no_data)
|
||||
{
|
||||
if (gradients_list)
|
||||
gradients_free ();
|
||||
|
@ -5694,6 +5694,9 @@ grad_free_gradient (gradient_t *grad)
|
|||
if (grad->filename)
|
||||
g_free (grad->filename);
|
||||
|
||||
if (grad->pixmap)
|
||||
gdk_pixmap_unref (grad->pixmap);
|
||||
|
||||
g_free (grad);
|
||||
}
|
||||
|
||||
|
@ -5724,7 +5727,7 @@ static void
|
|||
grad_free_gradients (void)
|
||||
{
|
||||
grad_save_all (TRUE);
|
||||
|
||||
|
||||
g_slist_free (gradients_list);
|
||||
|
||||
num_gradients = 0;
|
||||
|
|
|
@ -555,7 +555,7 @@ static guint n_gradient_targets = (sizeof (gradient_target_table) /
|
|||
/***** Public functions *****/
|
||||
|
||||
void
|
||||
gradients_init (int no_data)
|
||||
gradients_init (gint no_data)
|
||||
{
|
||||
if (gradients_list)
|
||||
gradients_free ();
|
||||
|
@ -5694,6 +5694,9 @@ grad_free_gradient (gradient_t *grad)
|
|||
if (grad->filename)
|
||||
g_free (grad->filename);
|
||||
|
||||
if (grad->pixmap)
|
||||
gdk_pixmap_unref (grad->pixmap);
|
||||
|
||||
g_free (grad);
|
||||
}
|
||||
|
||||
|
@ -5724,7 +5727,7 @@ static void
|
|||
grad_free_gradients (void)
|
||||
{
|
||||
grad_save_all (TRUE);
|
||||
|
||||
|
||||
g_slist_free (gradients_list);
|
||||
|
||||
num_gradients = 0;
|
||||
|
|
|
@ -331,11 +331,17 @@ palette_entries_free (PaletteEntries *entries)
|
|||
palette_entry_free (entry);
|
||||
}
|
||||
|
||||
g_free (entries->name);
|
||||
g_slist_free (entries->colors);
|
||||
|
||||
if (entries->name)
|
||||
g_free (entries->name);
|
||||
|
||||
if (entries->filename)
|
||||
g_free (entries->filename);
|
||||
|
||||
if (entries->pixmap)
|
||||
gdk_pixmap_unref (entries->pixmap);
|
||||
|
||||
g_free (entries);
|
||||
}
|
||||
|
||||
|
|
|
@ -331,11 +331,17 @@ palette_entries_free (PaletteEntries *entries)
|
|||
palette_entry_free (entry);
|
||||
}
|
||||
|
||||
g_free (entries->name);
|
||||
g_slist_free (entries->colors);
|
||||
|
||||
if (entries->name)
|
||||
g_free (entries->name);
|
||||
|
||||
if (entries->filename)
|
||||
g_free (entries->filename);
|
||||
|
||||
if (entries->pixmap)
|
||||
gdk_pixmap_unref (entries->pixmap);
|
||||
|
||||
g_free (entries);
|
||||
}
|
||||
|
||||
|
|
|
@ -555,7 +555,7 @@ static guint n_gradient_targets = (sizeof (gradient_target_table) /
|
|||
/***** Public functions *****/
|
||||
|
||||
void
|
||||
gradients_init (int no_data)
|
||||
gradients_init (gint no_data)
|
||||
{
|
||||
if (gradients_list)
|
||||
gradients_free ();
|
||||
|
@ -5694,6 +5694,9 @@ grad_free_gradient (gradient_t *grad)
|
|||
if (grad->filename)
|
||||
g_free (grad->filename);
|
||||
|
||||
if (grad->pixmap)
|
||||
gdk_pixmap_unref (grad->pixmap);
|
||||
|
||||
g_free (grad);
|
||||
}
|
||||
|
||||
|
@ -5724,7 +5727,7 @@ static void
|
|||
grad_free_gradients (void)
|
||||
{
|
||||
grad_save_all (TRUE);
|
||||
|
||||
|
||||
g_slist_free (gradients_list);
|
||||
|
||||
num_gradients = 0;
|
||||
|
|
|
@ -331,11 +331,17 @@ palette_entries_free (PaletteEntries *entries)
|
|||
palette_entry_free (entry);
|
||||
}
|
||||
|
||||
g_free (entries->name);
|
||||
g_slist_free (entries->colors);
|
||||
|
||||
if (entries->name)
|
||||
g_free (entries->name);
|
||||
|
||||
if (entries->filename)
|
||||
g_free (entries->filename);
|
||||
|
||||
if (entries->pixmap)
|
||||
gdk_pixmap_unref (entries->pixmap);
|
||||
|
||||
g_free (entries);
|
||||
}
|
||||
|
||||
|
|
|
@ -404,6 +404,8 @@ gimp_path_free (GList *path)
|
|||
* gimp_path_get_user_writable_dir:
|
||||
* @path: A list of directories as returned by gimp_path_parse().
|
||||
*
|
||||
* Note that you have to g_free() the returned string.
|
||||
*
|
||||
* Returns: The first directory in @path where the user has write permission.
|
||||
*
|
||||
*/
|
||||
|
|
|
@ -404,6 +404,8 @@ gimp_path_free (GList *path)
|
|||
* gimp_path_get_user_writable_dir:
|
||||
* @path: A list of directories as returned by gimp_path_parse().
|
||||
*
|
||||
* Note that you have to g_free() the returned string.
|
||||
*
|
||||
* Returns: The first directory in @path where the user has write permission.
|
||||
*
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue