applied patch from Jens Persson that adds a LUT to apply the jitter in

2007-07-04  Sven Neumann  <sven@gimp.org>

	* app/paint/gimpbrushcore.[ch]: applied patch from Jens Persson
	that adds a LUT to apply the jitter in polar coordinates (bug 
#434532).


svn path=/trunk/; revision=22859
This commit is contained in:
Sven Neumann 2007-07-04 06:30:34 +00:00 committed by Sven Neumann
parent 55ab925fe5
commit 62dbf9e330
3 changed files with 25 additions and 8 deletions

View File

@ -1,3 +1,8 @@
2007-07-04 Sven Neumann <sven@gimp.org>
* app/paint/gimpbrushcore.[ch]: applied patch from Jens Persson
that adds a LUT to apply the jitter in polar coordinates (bug #434532).
2007-07-02 Tor Lillqvist <tml@novell.com>
* configure.in: Fix bug in saving/restoring LDFLAGS around the

View File

@ -190,6 +190,14 @@ gimp_brush_core_init (GimpBrushCore *core)
core->last_scale_pixmap_width = 0;
core->last_scale_pixmap_height = 0;
for (i = 0; i < BRUSH_CORE_JITTER_LUTSIZE - 1; ++i)
{
core->jitter_lut_y[i] = cos (gimp_deg_to_rad (i * 360 /
BRUSH_CORE_JITTER_LUTSIZE));
core->jitter_lut_x[i] = sin (gimp_deg_to_rad (i * 360 /
BRUSH_CORE_JITTER_LUTSIZE));
}
g_assert (BRUSH_CORE_SUBSAMPLE == KERNEL_SUBSAMPLE);
for (i = 0; i < KERNEL_SUBSAMPLE + 1; i++)
@ -544,6 +552,7 @@ gimp_brush_core_interpolate (GimpPaintCore *paint_core,
x = (gint) floor (paint_core->last_coords.x + t0 * delta_vec.x);
y = (gint) floor (paint_core->last_coords.y + t0 * delta_vec.y);
if (t0 < 0.0 && !( x == (gint) floor (paint_core->last_coords.x) &&
y == (gint) floor (paint_core->last_coords.y) ))
{
@ -565,6 +574,7 @@ gimp_brush_core_interpolate (GimpPaintCore *paint_core,
x = (gint) floor (paint_core->last_coords.x + tn * delta_vec.x);
y = (gint) floor (paint_core->last_coords.y + tn * delta_vec.y);
if (tn > 1.0 && !( x == (gint) floor (paint_core->cur_coords.x) &&
y == (gint) floor (paint_core->cur_coords.y)))
{
@ -618,21 +628,20 @@ gimp_brush_core_interpolate (GimpPaintCore *paint_core,
if (core->jitter > 0.0)
{
gdouble jitter_x;
gdouble jitter_y;
gdouble jitter_dist;
gint32 jitter_angle;
jitter_x = g_rand_double_range (core->rand,
-core->jitter, core->jitter);
jitter_y = g_rand_double_range (core->rand,
-core->jitter, core->jitter);
jitter_dist = g_rand_double_range (core->rand, 0, core->jitter);
jitter_angle = g_rand_int_range (core->rand,
0, BRUSH_CORE_JITTER_LUTSIZE);
paint_core->cur_coords.x +=
(core->brush->x_axis.x + core->brush->y_axis.x) *
jitter_x * core->scale;
jitter_dist * core->jitter_lut_x[jitter_angle] * core->scale;
paint_core->cur_coords.y +=
(core->brush->y_axis.y + core->brush->x_axis.y) *
jitter_y * core->scale;
jitter_dist * core->jitter_lut_y[jitter_angle] * core->scale;
}
paint_core->distance = initial + t * dist;

View File

@ -25,6 +25,7 @@
#define BRUSH_CORE_SUBSAMPLE 4
#define BRUSH_CORE_SOLID_SUBSAMPLE 2
#define BRUSH_CORE_JITTER_LUTSIZE 360
#define PRESSURE_SCALE 1.5
@ -71,6 +72,8 @@ struct _GimpBrushCore
gboolean cache_invalid;
gdouble jitter;
gdouble jitter_lut_x[BRUSH_CORE_JITTER_LUTSIZE];
gdouble jitter_lut_y[BRUSH_CORE_JITTER_LUTSIZE];
GRand *rand;