gimp r28001 - in trunk: . app/core app/display app/paint app/tools
- From: mitch svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r28001 - in trunk: . app/core app/display app/paint app/tools
- Date: Sun, 8 Feb 2009 12:55:20 +0000 (UTC)
Author: mitch
Date: Sun Feb 8 12:55:20 2009
New Revision: 28001
URL: http://svn.gnome.org/viewvc/gimp?rev=28001&view=rev
Log:
2009-02-08 Michael Natterer <mitch gimp org>
Bug 520078 â Rotate brushes
Applied a slightly modified patch from Alexia Death:
* app/core/core-types.h (struct GimpCoords): add "direction" member.
* app/core/gimpcoords.c: take direction into account in mix(),
scalarprod(), length_squared(), manhattan_dist() and equal().
* app/core/gimpcoords-interpolate.c
(gimp_coords_interpolate_catmull): same here.
* app/display/gimpdisplayshell-coords.c
(gimp_display_shell_eval_event): same here.
* app/paint/gimppaintoptions.[ch]: add properties for direction
dynamics and adapt dynamics mixing accordingly.
* app/paint/gimpbrushcore.c (gimp_brush_core_interpolate):
"interpolate" direction too (in fact, just copy it from
last_coords since it doesn't change along a straight line).
* app/paint/gimppaintcore-stroke.c
(gimp_paint_core_stroke_emulate_dynamics): emulate direction too.
* app/tools/gimppaintoptions-gui.c: add GUI for direction dynamics.
Modified:
trunk/ChangeLog
trunk/app/core/core-types.h
trunk/app/core/gimpcoords-interpolate.c
trunk/app/core/gimpcoords.c
trunk/app/display/gimpdisplayshell-coords.c
trunk/app/paint/gimpbrushcore.c
trunk/app/paint/gimppaintcore-stroke.c
trunk/app/paint/gimppaintoptions.c
trunk/app/paint/gimppaintoptions.h
trunk/app/tools/gimppaintoptions-gui.c
Modified: trunk/app/core/core-types.h
==============================================================================
--- trunk/app/core/core-types.h (original)
+++ trunk/app/core/core-types.h Sun Feb 8 12:55:20 2009
@@ -199,6 +199,7 @@
gdouble ytilt;
gdouble wheel;
gdouble velocity;
+ gdouble direction;
};
Modified: trunk/app/core/gimpcoords-interpolate.c
==============================================================================
--- trunk/app/core/gimpcoords-interpolate.c (original)
+++ trunk/app/core/gimpcoords-interpolate.c Sun Feb 8 12:55:20 2009
@@ -255,7 +255,10 @@
for (n = 1; n <=num_points; n++)
{
GimpCoords res_coords;
+ GimpCoords last_coords;
gdouble velocity;
+ gdouble delta_x;
+ gdouble delta_y;
gdouble p = (gdouble) n / num_points;
res_coords.x =
@@ -306,6 +309,26 @@
future_coords.velocity);
res_coords.velocity = CLAMP (velocity, 0.0, 1.0);
+ if (n > 1)
+ last_coords = g_array_index (*ret_coords, GimpCoords, n - 2);
+ else
+ last_coords = start_coords;
+
+ delta_x = last_coords.x - res_coords.x;
+ delta_y = last_coords.y - res_coords.y;
+
+ if (delta_x == 0)
+ {
+ res_coords.direction = last_coords.direction;
+ }
+ else
+ {
+ res_coords.direction = atan (delta_y / delta_x) / (2 * G_PI);
+
+ if (delta_x > 0.0)
+ res_coords.direction = res_coords.direction + 0.5;
+ }
+
g_array_append_val (*ret_coords, res_coords);
if (ret_params)
Modified: trunk/app/core/gimpcoords.c
==============================================================================
--- trunk/app/core/gimpcoords.c (original)
+++ trunk/app/core/gimpcoords.c Sun Feb 8 12:55:20 2009
@@ -43,23 +43,25 @@
{
if (b)
{
- ret_val->x = amul * a->x + bmul * b->x;
- ret_val->y = amul * a->y + bmul * b->y;
- ret_val->pressure = amul * a->pressure + bmul * b->pressure;
- ret_val->xtilt = amul * a->xtilt + bmul * b->xtilt;
- ret_val->ytilt = amul * a->ytilt + bmul * b->ytilt;
- ret_val->wheel = amul * a->wheel + bmul * b->wheel;
- ret_val->velocity = amul * a->velocity + bmul * b->velocity;
+ ret_val->x = amul * a->x + bmul * b->x;
+ ret_val->y = amul * a->y + bmul * b->y;
+ ret_val->pressure = amul * a->pressure + bmul * b->pressure;
+ ret_val->xtilt = amul * a->xtilt + bmul * b->xtilt;
+ ret_val->ytilt = amul * a->ytilt + bmul * b->ytilt;
+ ret_val->wheel = amul * a->wheel + bmul * b->wheel;
+ ret_val->velocity = amul * a->velocity + bmul * b->velocity;
+ ret_val->direction = amul * a->direction + bmul * b->direction;
}
else
{
- ret_val->x = amul * a->x;
- ret_val->y = amul * a->y;
- ret_val->pressure = amul * a->pressure;
- ret_val->xtilt = amul * a->xtilt;
- ret_val->ytilt = amul * a->ytilt;
- ret_val->wheel = amul * a->wheel;
- ret_val->velocity = amul * a->velocity;
+ ret_val->x = amul * a->x;
+ ret_val->y = amul * a->y;
+ ret_val->pressure = amul * a->pressure;
+ ret_val->xtilt = amul * a->xtilt;
+ ret_val->ytilt = amul * a->ytilt;
+ ret_val->wheel = amul * a->wheel;
+ ret_val->velocity = amul * a->velocity;
+ ret_val->direction = amul * a->direction;
}
}
@@ -114,13 +116,14 @@
gimp_coords_scalarprod (const GimpCoords *a,
const GimpCoords *b)
{
- return (a->x * b->x +
- a->y * b->y +
- a->pressure * b->pressure +
- a->xtilt * b->xtilt +
- a->ytilt * b->ytilt +
- a->wheel * b->wheel +
- a->velocity * a->velocity);
+ return (a->x * b->x +
+ a->y * b->y +
+ a->pressure * b->pressure +
+ a->xtilt * b->xtilt +
+ a->ytilt * b->ytilt +
+ a->wheel * b->wheel +
+ a->velocity * b->velocity +
+ a->direction * b->direction);
}
@@ -135,13 +138,14 @@
{
GimpCoords upscaled_a;
- upscaled_a.x = a->x;
- upscaled_a.y = a->y;
- upscaled_a.pressure = a->pressure * INPUT_RESOLUTION;
- upscaled_a.xtilt = a->xtilt * INPUT_RESOLUTION;
- upscaled_a.ytilt = a->ytilt * INPUT_RESOLUTION;
- upscaled_a.wheel = a->wheel * INPUT_RESOLUTION;
- upscaled_a.velocity = a->velocity * INPUT_RESOLUTION;
+ upscaled_a.x = a->x;
+ upscaled_a.y = a->y;
+ upscaled_a.pressure = a->pressure * INPUT_RESOLUTION;
+ upscaled_a.xtilt = a->xtilt * INPUT_RESOLUTION;
+ upscaled_a.ytilt = a->ytilt * INPUT_RESOLUTION;
+ upscaled_a.wheel = a->wheel * INPUT_RESOLUTION;
+ upscaled_a.velocity = a->velocity * INPUT_RESOLUTION;
+ upscaled_a.direction = a->direction * INPUT_RESOLUTION;
return gimp_coords_scalarprod (&upscaled_a, &upscaled_a);
}
@@ -169,6 +173,7 @@
dist += ABS (a->ytilt - b->ytilt);
dist += ABS (a->wheel - b->wheel);
dist += ABS (a->velocity - b->velocity);
+ dist += ABS (a->direction - b->direction);
dist *= INPUT_RESOLUTION;
@@ -182,11 +187,12 @@
gimp_coords_equal (const GimpCoords *a,
const GimpCoords *b)
{
- return ( a->x == b->x &&
- a->y == b->y &&
- a->pressure == b->pressure &&
- a->xtilt == b->xtilt &&
- a->ytilt == b->ytilt &&
- a->wheel == b->wheel &&
- a->velocity == b->velocity);
+ return (a->x == b->x &&
+ a->y == b->y &&
+ a->pressure == b->pressure &&
+ a->xtilt == b->xtilt &&
+ a->ytilt == b->ytilt &&
+ a->wheel == b->wheel &&
+ a->velocity == b->velocity &&
+ a->direction == b->direction);
}
Modified: trunk/app/display/gimpdisplayshell-coords.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-coords.c (original)
+++ trunk/app/display/gimpdisplayshell-coords.c Sun Feb 8 12:55:20 2009
@@ -224,6 +224,7 @@
gdouble delta_y = 0.0;
gdouble distance = 1.0;
gboolean event_fill = (inertia_factor > 0);
+ gint i;
/* Smoothing causes problems with cursor tracking
* when zoomed above screen resolution so we need to supress it.
@@ -291,6 +292,17 @@
coords->velocity = MIN (coords->velocity, 1.0);
}
+ if (delta_x == 0)
+ {
+ coords->direction = shell->last_coords.direction;
+ }
+ else
+ {
+ coords->direction = atan (delta_y / delta_x) / (2 * G_PI);
+ if (delta_x > 0.0)
+ coords->direction = coords->direction + 0.5;
+ }
+
/* High speed -> less smooth*/
inertia_factor *= (1 - coords->velocity);
@@ -387,9 +399,10 @@
#endif
}
- shell->last_coords = *coords;
g_array_append_val (shell->event_queue, *coords);
+
+ shell->last_coords = *coords;
shell->last_motion_time = time;
shell->last_motion_delta_time = delta_time;
shell->last_motion_delta_x = delta_x;
Modified: trunk/app/paint/gimpbrushcore.c
==============================================================================
--- trunk/app/paint/gimpbrushcore.c (original)
+++ trunk/app/paint/gimpbrushcore.c Sun Feb 8 12:55:20 2009
@@ -421,6 +421,7 @@
gdouble delta_xtilt, delta_ytilt;
gdouble delta_wheel;
gdouble delta_velocity;
+ gdouble temp_direction;
GimpVector2 temp_vec;
gint n, num_points;
gdouble t0, dt, tn;
@@ -447,6 +448,7 @@
delta_ytilt = paint_core->cur_coords.ytilt - paint_core->last_coords.ytilt;
delta_wheel = paint_core->cur_coords.wheel - paint_core->last_coords.wheel;
delta_velocity = paint_core->cur_coords.velocity - paint_core->last_coords.velocity;
+ temp_direction = paint_core->cur_coords.direction;
/* return if there has been no motion */
if (! delta_vec.x &&
@@ -636,20 +638,21 @@
gdouble t = t0 + n * dt;
gdouble p = (gdouble) n / num_points;
- paint_core->cur_coords.x = (paint_core->last_coords.x +
- t * delta_vec.x);
- paint_core->cur_coords.y = (paint_core->last_coords.y +
- t * delta_vec.y);
- paint_core->cur_coords.pressure = (paint_core->last_coords.pressure +
- p * delta_pressure);
- paint_core->cur_coords.xtilt = (paint_core->last_coords.xtilt +
- p * delta_xtilt);
- paint_core->cur_coords.ytilt = (paint_core->last_coords.ytilt +
- p * delta_ytilt);
- paint_core->cur_coords.wheel = (paint_core->last_coords.wheel +
- p * delta_wheel);
- paint_core->cur_coords.velocity = (paint_core->last_coords.velocity +
- p * delta_velocity);
+ paint_core->cur_coords.x = (paint_core->last_coords.x +
+ t * delta_vec.x);
+ paint_core->cur_coords.y = (paint_core->last_coords.y +
+ t * delta_vec.y);
+ paint_core->cur_coords.pressure = (paint_core->last_coords.pressure +
+ p * delta_pressure);
+ paint_core->cur_coords.xtilt = (paint_core->last_coords.xtilt +
+ p * delta_xtilt);
+ paint_core->cur_coords.ytilt = (paint_core->last_coords.ytilt +
+ p * delta_ytilt);
+ paint_core->cur_coords.wheel = (paint_core->last_coords.wheel +
+ p * delta_wheel);
+ paint_core->cur_coords.velocity = (paint_core->last_coords.velocity +
+ p * delta_velocity);
+ paint_core->cur_coords.direction = temp_direction;
if (core->jitter > 0.0)
{
Modified: trunk/app/paint/gimppaintcore-stroke.c
==============================================================================
--- trunk/app/paint/gimppaintcore-stroke.c (original)
+++ trunk/app/paint/gimppaintcore-stroke.c Sun Feb 8 12:55:20 2009
@@ -19,6 +19,8 @@
#include <gegl.h>
+#include "libgimpmath/gimpmath.h"
+
#include "paint-types.h"
#include "base/boundary.h"
@@ -39,6 +41,7 @@
static void gimp_paint_core_stroke_emulate_dynamics (GimpCoords *coords,
gint length);
+
static const GimpCoords default_coords = GIMP_COORDS_DEFAULT_VALUES;
@@ -374,4 +377,39 @@
coords[i].velocity = i * slope;
}
}
+
+ if (length > 0)
+ {
+ gint i;
+
+ /* Fill in direction */
+ for (i = 2; i < length; i++)
+ {
+ gdouble delta_x = coords[i - 1].x - coords[i].x;
+ gdouble delta_y = coords[i - 1].y - coords[i].y;
+
+ if (delta_x == 0)
+ {
+ coords[i].direction = coords[i - 1].direction;
+ }
+ else
+ {
+ coords[i].direction = atan (delta_y / delta_x) / (2 * G_PI);
+ if (delta_x > 0.0)
+ coords[i].direction = coords[i].direction + 0.5;
+ }
+
+ /* This should avoid confusing the interpolator on sharp
+ * turns where the angle warps
+ */
+ if (fabs (coords[i].direction - coords[i - 1].direction) > 0.5)
+ coords[i].direction = coords[i].direction + 1.0;
+ }
+
+ if (length > 2)
+ {
+ coords[0].direction = coords[2].direction;
+ coords[1].direction = coords[2].direction;
+ }
+ }
}
Modified: trunk/app/paint/gimppaintoptions.c
==============================================================================
--- trunk/app/paint/gimppaintoptions.c (original)
+++ trunk/app/paint/gimppaintoptions.c Sun Feb 8 12:55:20 2009
@@ -33,53 +33,62 @@
#include "gimppaintoptions.h"
-#define DEFAULT_BRUSH_SCALE 1.0
-#define DEFAULT_BRUSH_ANGLE 0.0
+#define DEFAULT_BRUSH_SCALE 1.0
+#define DEFAULT_BRUSH_ANGLE 0.0
-#define DEFAULT_APPLICATION_MODE GIMP_PAINT_CONSTANT
-#define DEFAULT_HARD FALSE
+#define DEFAULT_APPLICATION_MODE GIMP_PAINT_CONSTANT
+#define DEFAULT_HARD FALSE
-#define DEFAULT_DYNAMICS_EXPANDED FALSE
+#define DEFAULT_DYNAMICS_EXPANDED FALSE
-#define DEFAULT_PRESSURE_OPACITY TRUE
-#define DEFAULT_PRESSURE_HARDNESS FALSE
-#define DEFAULT_PRESSURE_RATE FALSE
-#define DEFAULT_PRESSURE_SIZE FALSE
-#define DEFAULT_PRESSURE_INVERSE_SIZE FALSE
-#define DEFAULT_PRESSURE_COLOR FALSE
-#define DEFAULT_PRESSURE_ANGLE FALSE
-#define DEFAULT_PRESSURE_PRESCALE 1.0
-
-#define DEFAULT_VELOCITY_OPACITY FALSE
-#define DEFAULT_VELOCITY_HARDNESS FALSE
-#define DEFAULT_VELOCITY_RATE FALSE
-#define DEFAULT_VELOCITY_SIZE FALSE
-#define DEFAULT_VELOCITY_INVERSE_SIZE FALSE
-#define DEFAULT_VELOCITY_COLOR FALSE
-#define DEFAULT_VELOCITY_ANGLE FALSE
-#define DEFAULT_VELOCITY_PRESCALE 1.0
-
-#define DEFAULT_RANDOM_OPACITY FALSE
-#define DEFAULT_RANDOM_HARDNESS FALSE
-#define DEFAULT_RANDOM_RATE FALSE
-#define DEFAULT_RANDOM_SIZE FALSE
-#define DEFAULT_RANDOM_INVERSE_SIZE FALSE
-#define DEFAULT_RANDOM_COLOR FALSE
-#define DEFAULT_RANDOM_ANGLE FALSE
-#define DEFAULT_RANDOM_PRESCALE 1.0
-
-#define DEFAULT_USE_FADE FALSE
-#define DEFAULT_FADE_LENGTH 100.0
-#define DEFAULT_FADE_UNIT GIMP_UNIT_PIXEL
-
-#define DEFAULT_USE_JITTER FALSE
-#define DEFAULT_JITTER_AMOUNT 0.2
-
-#define DEFAULT_USE_GRADIENT FALSE
-#define DEFAULT_GRADIENT_REVERSE FALSE
-#define DEFAULT_GRADIENT_REPEAT GIMP_REPEAT_TRIANGULAR
-#define DEFAULT_GRADIENT_LENGTH 100.0
-#define DEFAULT_GRADIENT_UNIT GIMP_UNIT_PIXEL
+#define DEFAULT_PRESSURE_OPACITY TRUE
+#define DEFAULT_PRESSURE_HARDNESS FALSE
+#define DEFAULT_PRESSURE_RATE FALSE
+#define DEFAULT_PRESSURE_SIZE FALSE
+#define DEFAULT_PRESSURE_INVERSE_SIZE FALSE
+#define DEFAULT_PRESSURE_COLOR FALSE
+#define DEFAULT_PRESSURE_ANGLE FALSE
+#define DEFAULT_PRESSURE_PRESCALE 1.0
+
+#define DEFAULT_VELOCITY_OPACITY FALSE
+#define DEFAULT_VELOCITY_HARDNESS FALSE
+#define DEFAULT_VELOCITY_RATE FALSE
+#define DEFAULT_VELOCITY_SIZE FALSE
+#define DEFAULT_VELOCITY_INVERSE_SIZE FALSE
+#define DEFAULT_VELOCITY_COLOR FALSE
+#define DEFAULT_VELOCITY_ANGLE FALSE
+#define DEFAULT_VELOCITY_PRESCALE 1.0
+
+#define DEFAULT_DIRECTION_OPACITY FALSE
+#define DEFAULT_DIRECTION_HARDNESS FALSE
+#define DEFAULT_DIRECTION_RATE FALSE
+#define DEFAULT_DIRECTION_SIZE FALSE
+#define DEFAULT_DIRECTION_INVERSE_SIZE FALSE
+#define DEFAULT_DIRECTION_COLOR FALSE
+#define DEFAULT_DIRECTION_ANGLE FALSE
+#define DEFAULT_DIRECTION_PRESCALE 1.0
+
+#define DEFAULT_RANDOM_OPACITY FALSE
+#define DEFAULT_RANDOM_HARDNESS FALSE
+#define DEFAULT_RANDOM_RATE FALSE
+#define DEFAULT_RANDOM_SIZE FALSE
+#define DEFAULT_RANDOM_INVERSE_SIZE FALSE
+#define DEFAULT_RANDOM_COLOR FALSE
+#define DEFAULT_RANDOM_ANGLE FALSE
+#define DEFAULT_RANDOM_PRESCALE 1.0
+
+#define DEFAULT_USE_FADE FALSE
+#define DEFAULT_FADE_LENGTH 100.0
+#define DEFAULT_FADE_UNIT GIMP_UNIT_PIXEL
+
+#define DEFAULT_USE_JITTER FALSE
+#define DEFAULT_JITTER_AMOUNT 0.2
+
+#define DEFAULT_USE_GRADIENT FALSE
+#define DEFAULT_GRADIENT_REVERSE FALSE
+#define DEFAULT_GRADIENT_REPEAT GIMP_REPEAT_TRIANGULAR
+#define DEFAULT_GRADIENT_LENGTH 100.0
+#define DEFAULT_GRADIENT_UNIT GIMP_UNIT_PIXEL
enum
@@ -114,6 +123,15 @@
PROP_VELOCITY_ANGLE,
PROP_VELOCITY_PRESCALE,
+ PROP_DIRECTION_OPACITY,
+ PROP_DIRECTION_HARDNESS,
+ PROP_DIRECTION_RATE,
+ PROP_DIRECTION_SIZE,
+ PROP_DIRECTION_INVERSE_SIZE,
+ PROP_DIRECTION_COLOR,
+ PROP_DIRECTION_ANGLE,
+ PROP_DIRECTION_PRESCALE,
+
PROP_RANDOM_OPACITY,
PROP_RANDOM_HARDNESS,
PROP_RANDOM_RATE,
@@ -162,7 +180,9 @@
gdouble mix2,
gdouble mix2_scale,
gdouble mix3,
- gdouble mix3_scale);
+ gdouble mix3_scale,
+ gdouble mix4,
+ gdouble mix4_scale);
G_DEFINE_TYPE (GimpPaintOptions, gimp_paint_options, GIMP_TYPE_TOOL_OPTIONS)
@@ -277,6 +297,39 @@
0.0, 1.0, DEFAULT_VELOCITY_PRESCALE,
GIMP_PARAM_STATIC_STRINGS);
+ GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_DIRECTION_OPACITY,
+ "direction-opacity", NULL,
+ DEFAULT_DIRECTION_OPACITY,
+ GIMP_PARAM_STATIC_STRINGS);
+ GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_DIRECTION_HARDNESS,
+ "direction-hardness", NULL,
+ DEFAULT_DIRECTION_HARDNESS,
+ GIMP_PARAM_STATIC_STRINGS);
+ GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_DIRECTION_RATE,
+ "direction-rate", NULL,
+ DEFAULT_DIRECTION_RATE,
+ GIMP_PARAM_STATIC_STRINGS);
+ GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_DIRECTION_SIZE,
+ "direction-size", NULL,
+ DEFAULT_DIRECTION_SIZE,
+ GIMP_PARAM_STATIC_STRINGS);
+ GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_DIRECTION_COLOR,
+ "direction-color", NULL,
+ DEFAULT_DIRECTION_COLOR,
+ GIMP_PARAM_STATIC_STRINGS);
+ GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_DIRECTION_ANGLE,
+ "direction-angle", NULL,
+ DEFAULT_DIRECTION_ANGLE,
+ GIMP_PARAM_STATIC_STRINGS);
+ GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_DIRECTION_INVERSE_SIZE,
+ "direction-inverse-size", NULL,
+ DEFAULT_DIRECTION_INVERSE_SIZE,
+ GIMP_PARAM_STATIC_STRINGS);
+ GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_DIRECTION_PRESCALE,
+ "direction-prescale", NULL,
+ 0.0, 1.0, DEFAULT_DIRECTION_PRESCALE,
+ GIMP_PARAM_STATIC_STRINGS);
+
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_RANDOM_OPACITY,
"random-opacity", NULL,
DEFAULT_RANDOM_OPACITY,
@@ -299,7 +352,7 @@
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_RANDOM_ANGLE,
"random-angle", NULL,
- DEFAULT_RANDOM_COLOR,
+ DEFAULT_RANDOM_ANGLE,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_RANDOM_INVERSE_SIZE,
"random-inverse-size", NULL,
@@ -396,12 +449,13 @@
{
options->application_mode_save = DEFAULT_APPLICATION_MODE;
- options->pressure_options = g_slice_new0 (GimpDynamicOptions);
- options->velocity_options = g_slice_new0 (GimpDynamicOptions);
- options->random_options = g_slice_new0 (GimpDynamicOptions);
- options->fade_options = g_slice_new0 (GimpFadeOptions);
- options->jitter_options = g_slice_new0 (GimpJitterOptions);
- options->gradient_options = g_slice_new0 (GimpGradientOptions);
+ options->pressure_options = g_slice_new0 (GimpDynamicOptions);
+ options->velocity_options = g_slice_new0 (GimpDynamicOptions);
+ options->direction_options = g_slice_new0 (GimpDynamicOptions);
+ options->random_options = g_slice_new0 (GimpDynamicOptions);
+ options->fade_options = g_slice_new0 (GimpFadeOptions);
+ options->jitter_options = g_slice_new0 (GimpJitterOptions);
+ options->gradient_options = g_slice_new0 (GimpGradientOptions);
}
static void
@@ -414,6 +468,7 @@
g_slice_free (GimpDynamicOptions, options->pressure_options);
g_slice_free (GimpDynamicOptions, options->velocity_options);
+ g_slice_free (GimpDynamicOptions, options->direction_options);
g_slice_free (GimpDynamicOptions, options->random_options);
g_slice_free (GimpFadeOptions, options->fade_options);
g_slice_free (GimpJitterOptions, options->jitter_options);
@@ -428,13 +483,14 @@
const GValue *value,
GParamSpec *pspec)
{
- GimpPaintOptions *options = GIMP_PAINT_OPTIONS (object);
- GimpDynamicOptions *pressure_options = options->pressure_options;
- GimpDynamicOptions *velocity_options = options->velocity_options;
- GimpDynamicOptions *random_options = options->random_options;
- GimpFadeOptions *fade_options = options->fade_options;
- GimpJitterOptions *jitter_options = options->jitter_options;
- GimpGradientOptions *gradient_options = options->gradient_options;
+ GimpPaintOptions *options = GIMP_PAINT_OPTIONS (object);
+ GimpDynamicOptions *pressure_options = options->pressure_options;
+ GimpDynamicOptions *velocity_options = options->velocity_options;
+ GimpDynamicOptions *direction_options = options->direction_options;
+ GimpDynamicOptions *random_options = options->random_options;
+ GimpFadeOptions *fade_options = options->fade_options;
+ GimpJitterOptions *jitter_options = options->jitter_options;
+ GimpGradientOptions *gradient_options = options->gradient_options;
switch (property_id)
{
@@ -526,6 +582,38 @@
velocity_options->prescale = g_value_get_double (value);
break;
+ case PROP_DIRECTION_OPACITY:
+ direction_options->opacity = g_value_get_boolean (value);
+ break;
+
+ case PROP_DIRECTION_HARDNESS:
+ direction_options->hardness = g_value_get_boolean (value);
+ break;
+
+ case PROP_DIRECTION_RATE:
+ direction_options->rate = g_value_get_boolean (value);
+ break;
+
+ case PROP_DIRECTION_SIZE:
+ direction_options->size = g_value_get_boolean (value);
+ break;
+
+ case PROP_DIRECTION_INVERSE_SIZE:
+ direction_options->inverse_size = g_value_get_boolean (value);
+ break;
+
+ case PROP_DIRECTION_COLOR:
+ direction_options->color = g_value_get_boolean (value);
+ break;
+
+ case PROP_DIRECTION_ANGLE:
+ direction_options->angle = g_value_get_boolean (value);
+ break;
+
+ case PROP_DIRECTION_PRESCALE:
+ direction_options->prescale = g_value_get_double (value);
+ break;
+
case PROP_RANDOM_OPACITY:
random_options->opacity = g_value_get_boolean (value);
break;
@@ -634,13 +722,14 @@
GValue *value,
GParamSpec *pspec)
{
- GimpPaintOptions *options = GIMP_PAINT_OPTIONS (object);
- GimpDynamicOptions *pressure_options = options->pressure_options;
- GimpDynamicOptions *velocity_options = options->velocity_options;
- GimpDynamicOptions *random_options = options->random_options;
- GimpFadeOptions *fade_options = options->fade_options;
- GimpJitterOptions *jitter_options = options->jitter_options;
- GimpGradientOptions *gradient_options = options->gradient_options;
+ GimpPaintOptions *options = GIMP_PAINT_OPTIONS (object);
+ GimpDynamicOptions *pressure_options = options->pressure_options;
+ GimpDynamicOptions *velocity_options = options->velocity_options;
+ GimpDynamicOptions *direction_options = options->direction_options;
+ GimpDynamicOptions *random_options = options->random_options;
+ GimpFadeOptions *fade_options = options->fade_options;
+ GimpJitterOptions *jitter_options = options->jitter_options;
+ GimpGradientOptions *gradient_options = options->gradient_options;
switch (property_id)
{
@@ -732,6 +821,38 @@
g_value_set_double (value, velocity_options->prescale);
break;
+ case PROP_DIRECTION_OPACITY:
+ g_value_set_boolean (value, direction_options->opacity);
+ break;
+
+ case PROP_DIRECTION_HARDNESS:
+ g_value_set_boolean (value, direction_options->hardness);
+ break;
+
+ case PROP_DIRECTION_RATE:
+ g_value_set_boolean (value, direction_options->rate);
+ break;
+
+ case PROP_DIRECTION_SIZE:
+ g_value_set_boolean (value, direction_options->size);
+ break;
+
+ case PROP_DIRECTION_INVERSE_SIZE:
+ g_value_set_boolean (value, direction_options->inverse_size);
+ break;
+
+ case PROP_DIRECTION_COLOR:
+ g_value_set_boolean (value, direction_options->color);
+ break;
+
+ case PROP_DIRECTION_ANGLE:
+ g_value_set_boolean (value, direction_options->angle);
+ break;
+
+ case PROP_DIRECTION_PRESCALE:
+ g_value_set_double (value, direction_options->prescale);
+ break;
+
case PROP_RANDOM_OPACITY:
g_value_set_boolean (value, random_options->opacity);
break;
@@ -968,8 +1089,9 @@
gradient = gimp_context_get_gradient (GIMP_CONTEXT (paint_options));
- if (paint_options->pressure_options->color ||
- paint_options->velocity_options->color ||
+ if (paint_options->pressure_options->color ||
+ paint_options->velocity_options->color ||
+ paint_options->direction_options->color ||
paint_options->random_options->color)
{
gimp_gradient_get_color_at (gradient, GIMP_CONTEXT (paint_options),
@@ -1061,34 +1183,43 @@
gdouble mix2,
gdouble mix2_scale,
gdouble mix3,
- gdouble mix3_scale)
+ gdouble mix3_scale,
+ gdouble mix4,
+ gdouble mix4_scale)
{
gdouble scale_sum = 0.0;
gdouble result = 1.0;
- if (mix1 >= 0.0)
+ if (mix1 > -1.0)
{
scale_sum += fabs (mix1_scale);
}
else mix1 = 0.0;
- if (mix2 >= 0.0)
+ if (mix2 > -1.0)
{
scale_sum += fabs (mix2_scale);
}
else mix2 = 0.0;
- if (mix3 >= 0.0)
+ if (mix3 > -1.0)
{
scale_sum += fabs (mix3_scale);
}
else mix3 = 0.0;
+ if (mix4 > -1.0)
+ {
+ scale_sum += fabs (mix4_scale);
+ }
+ else mix4 = 0.0;
+
if (scale_sum > 0.0)
{
result = (mix1 * mix1_scale) / scale_sum +
(mix2 * mix2_scale) / scale_sum +
- (mix3 * mix3_scale) / scale_sum;
+ (mix3 * mix3_scale) / scale_sum +
+ (mix4 * mix4_scale) / scale_sum;
}
if (result < 0.0)
@@ -1106,13 +1237,15 @@
g_return_val_if_fail (GIMP_IS_PAINT_OPTIONS (paint_options), 1.0);
g_return_val_if_fail (coords != NULL, 1.0);
- if (paint_options->pressure_options->opacity ||
- paint_options->velocity_options->opacity ||
+ if (paint_options->pressure_options->opacity ||
+ paint_options->velocity_options->opacity ||
+ paint_options->direction_options->opacity ||
paint_options->random_options->opacity)
{
- gdouble pressure = -1.0;
- gdouble velocity = -1.0;
- gdouble random = -1.0;
+ gdouble pressure = -1.0;
+ gdouble velocity = -1.0;
+ gdouble direction = -1.0;
+ gdouble random = -1.0;
if (paint_options->pressure_options->opacity)
pressure = GIMP_PAINT_PRESSURE_SCALE * coords->pressure;
@@ -1123,12 +1256,17 @@
if (paint_options->random_options->opacity)
random = g_random_double_range (0.0, 1.0);
+ if (paint_options->direction_options->opacity)
+ direction = coords->direction + 0.5; /* mixer does not mix negative angles right so we shift */
+
opacity = gimp_paint_options_get_dynamics_mix (pressure,
paint_options->pressure_options->prescale,
velocity,
paint_options->velocity_options->prescale,
random,
- paint_options->random_options->prescale);
+ paint_options->random_options->prescale,
+ direction,
+ paint_options->direction_options->prescale);
}
return opacity;
@@ -1143,9 +1281,10 @@
if (use_dynamics)
{
- gdouble pressure = -1.0;
- gdouble velocity = -1.0;
- gdouble random = -1.0;
+ gdouble pressure = -1.0;
+ gdouble velocity = -1.0;
+ gdouble direction = -1.0;
+ gdouble random = -1.0;
if (paint_options->pressure_options->size)
{
@@ -1174,12 +1313,17 @@
random = g_random_double_range (0.0, 1.0);
}
+ if (paint_options->direction_options->size)
+ direction = coords->direction + 0.5; /* mixer does not mix negative angles right so we shift */
+
scale = gimp_paint_options_get_dynamics_mix (pressure,
paint_options->pressure_options->prescale,
velocity,
paint_options->velocity_options->prescale,
random,
- paint_options->random_options->prescale);
+ paint_options->random_options->prescale,
+ direction,
+ paint_options->direction_options->prescale);
if (scale < 1 / 64.0)
scale = 1 / 8.0;
@@ -1202,13 +1346,15 @@
g_return_val_if_fail (GIMP_IS_PAINT_OPTIONS (paint_options), 1.0);
g_return_val_if_fail (coords != NULL, 1.0);
- if (paint_options->pressure_options->rate ||
- paint_options->velocity_options->rate ||
+ if (paint_options->pressure_options->rate ||
+ paint_options->velocity_options->rate ||
+ paint_options->direction_options->rate ||
paint_options->random_options->rate)
{
- gdouble pressure = -1.0;
- gdouble velocity = -1.0;
- gdouble random = -1.0;
+ gdouble pressure = -1.0;
+ gdouble velocity = -1.0;
+ gdouble direction = -1.0;
+ gdouble random = -1.0;
if (paint_options->pressure_options->rate)
pressure = GIMP_PAINT_PRESSURE_SCALE * coords->pressure;
@@ -1219,12 +1365,17 @@
if (paint_options->random_options->rate)
random = g_random_double_range (0.0, 1.0);
+ if (paint_options->direction_options->rate)
+ direction = coords->direction + 0.5; /* mixer does not mix negative angles right so we shift */
+
rate = gimp_paint_options_get_dynamics_mix (pressure,
paint_options->pressure_options->prescale,
velocity,
paint_options->velocity_options->prescale,
random,
- paint_options->random_options->prescale);
+ paint_options->random_options->prescale,
+ direction,
+ paint_options->direction_options->prescale);
}
return rate;
@@ -1240,13 +1391,15 @@
g_return_val_if_fail (GIMP_IS_PAINT_OPTIONS (paint_options), 1.0);
g_return_val_if_fail (coords != NULL, 1.0);
- if (paint_options->pressure_options->color ||
- paint_options->velocity_options->color ||
+ if (paint_options->pressure_options->color ||
+ paint_options->velocity_options->color ||
+ paint_options->direction_options->color ||
paint_options->random_options->color)
{
- gdouble pressure = -1.0;
- gdouble velocity = -1.0;
- gdouble random = -1.0;
+ gdouble pressure = -1.0;
+ gdouble velocity = -1.0;
+ gdouble direction = -1.0;
+ gdouble random = -1.0;
if (paint_options->pressure_options->color)
pressure = GIMP_PAINT_PRESSURE_SCALE * coords->pressure;
@@ -1257,12 +1410,17 @@
if (paint_options->random_options->color)
random = g_random_double_range (0.0, 1.0);
+ if (paint_options->direction_options->color)
+ direction = coords->direction + 0.5; /* mixer does not mix negative angles right so we shift */
+
color = gimp_paint_options_get_dynamics_mix (pressure,
paint_options->pressure_options->prescale,
velocity,
paint_options->velocity_options->prescale,
random,
- paint_options->random_options->prescale);
+ paint_options->random_options->prescale,
+ direction,
+ paint_options->direction_options->prescale);
}
return color;
@@ -1277,13 +1435,15 @@
g_return_val_if_fail (GIMP_IS_PAINT_OPTIONS (paint_options), 1.0);
g_return_val_if_fail (coords != NULL, 1.0);
- if (paint_options->pressure_options->hardness ||
- paint_options->velocity_options->hardness ||
+ if (paint_options->pressure_options->hardness ||
+ paint_options->velocity_options->hardness ||
+ paint_options->direction_options->hardness ||
paint_options->random_options->hardness)
{
- gdouble pressure = -1.0;
- gdouble velocity = -1.0;
- gdouble random = -1.0;
+ gdouble pressure = -1.0;
+ gdouble velocity = -1.0;
+ gdouble direction = -1.0;
+ gdouble random = -1.0;
if (paint_options->pressure_options->hardness)
pressure = GIMP_PAINT_PRESSURE_SCALE * coords->pressure;
@@ -1294,12 +1454,17 @@
if (paint_options->random_options->hardness)
random = g_random_double_range (0.0, 1.0);
+ if (paint_options->direction_options->hardness)
+ direction = coords->direction + 0.5; /* mixer does not mix negative angles right so we shift */
+
hardness = gimp_paint_options_get_dynamics_mix (pressure,
paint_options->pressure_options->prescale,
velocity,
paint_options->velocity_options->prescale,
random,
- paint_options->random_options->prescale);
+ paint_options->random_options->prescale,
+ direction,
+ paint_options->direction_options->prescale);
}
return hardness;
@@ -1314,13 +1479,15 @@
g_return_val_if_fail (GIMP_IS_PAINT_OPTIONS (paint_options), 1.0);
g_return_val_if_fail (coords != NULL, 1.0);
- if (paint_options->pressure_options->angle ||
- paint_options->velocity_options->angle ||
+ if (paint_options->pressure_options->angle ||
+ paint_options->velocity_options->angle ||
+ paint_options->direction_options->angle ||
paint_options->random_options->angle)
{
- gdouble pressure = -1.0;
- gdouble velocity = -1.0;
- gdouble random = -1.0;
+ gdouble pressure = -1.0;
+ gdouble velocity = -1.0;
+ gdouble direction = -1.0;
+ gdouble random = -1.0;
if (paint_options->pressure_options->angle)
pressure = GIMP_PAINT_PRESSURE_SCALE * coords->pressure;
@@ -1331,12 +1498,19 @@
if (paint_options->random_options->angle)
random = g_random_double_range (0.0, 1.0);
+ if (paint_options->direction_options->angle)
+ direction = coords->direction + 0.5; /* mixer does not mix negative angles right so we shift */
+
+
angle = gimp_paint_options_get_dynamics_mix (pressure,
- paint_options->pressure_options->prescale,
- velocity,
- paint_options->velocity_options->prescale,
- random,
- paint_options->random_options->prescale);
+ paint_options->pressure_options->prescale,
+ velocity,
+ paint_options->velocity_options->prescale,
+ random,
+ paint_options->random_options->prescale,
+ direction,
+ paint_options->direction_options->prescale);
+ angle = angle - 0.5;
}
return angle + paint_options->brush_angle;
Modified: trunk/app/paint/gimppaintoptions.h
==============================================================================
--- trunk/app/paint/gimppaintoptions.h (original)
+++ trunk/app/paint/gimppaintoptions.h Sun Feb 8 12:55:20 2009
@@ -98,6 +98,7 @@
gboolean dynamics_expanded;
GimpDynamicOptions *pressure_options;
GimpDynamicOptions *velocity_options;
+ GimpDynamicOptions *direction_options;
GimpDynamicOptions *random_options;
GimpFadeOptions *fade_options;
Modified: trunk/app/tools/gimppaintoptions-gui.c
==============================================================================
--- trunk/app/tools/gimppaintoptions-gui.c (original)
+++ trunk/app/tools/gimppaintoptions-gui.c Sun Feb 8 12:55:20 2009
@@ -54,26 +54,30 @@
static gboolean tool_has_color_dynamics (GType tool_type);
static gboolean tool_has_angle_dynamics (GType tool_type);
-static void pressure_options_gui (GimpPaintOptions *paint_options,
- GType tool_type,
- GtkTable *table,
- gint row,
- GtkWidget *labels[]);
-static void velocity_options_gui (GimpPaintOptions *paint_options,
- GType tool_type,
- GtkTable *table,
- gint row);
-static void random_options_gui (GimpPaintOptions *paint_options,
- GType tool_type,
- GtkTable *table,
- gint row);
-static GtkWidget * fade_options_gui (GimpPaintOptions *paint_options,
- GType tool_type);
-static GtkWidget * gradient_options_gui (GimpPaintOptions *paint_options,
- GType tool_type,
- GtkWidget *incremental_toggle);
-static GtkWidget * jitter_options_gui (GimpPaintOptions *paint_options,
- GType tool_type);
+static void pressure_options_gui (GimpPaintOptions *paint_options,
+ GType tool_type,
+ GtkTable *table,
+ gint row,
+ GtkWidget *labels[]);
+static void velocity_options_gui (GimpPaintOptions *paint_options,
+ GType tool_type,
+ GtkTable *table,
+ gint row);
+static void direction_options_gui (GimpPaintOptions *paint_options,
+ GType tool_type,
+ GtkTable *table,
+ gint row);
+static void random_options_gui (GimpPaintOptions *paint_options,
+ GType tool_type,
+ GtkTable *table,
+ gint row);
+static GtkWidget * fade_options_gui (GimpPaintOptions *paint_options,
+ GType tool_type);
+static GtkWidget * gradient_options_gui (GimpPaintOptions *paint_options,
+ GType tool_type,
+ GtkWidget *incremental_toggle);
+static GtkWidget * jitter_options_gui (GimpPaintOptions *paint_options,
+ GType tool_type);
/* public functions */
@@ -150,8 +154,6 @@
_("Angle:"),
1.0, 5.0, 2,
FALSE, 0.0, 0.0);
- gimp_scale_entry_set_logarithmic (adj_angle, FALSE);
-
}
if (tool_has_opacity_dynamics (tool_type))
@@ -206,7 +208,7 @@
gtk_container_add (GTK_CONTAINER (frame), inner_frame);
gtk_widget_show (inner_frame);
- table = gtk_table_new (4, n_dynamics + 2, FALSE);
+ table = gtk_table_new (5, n_dynamics + 2, FALSE);
gtk_container_add (GTK_CONTAINER (inner_frame), table);
gtk_widget_show (table);
@@ -222,12 +224,18 @@
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show (label);
- label = gtk_label_new (_("Random:"));
+ label = gtk_label_new (_("Direction:"));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 3, 4,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show (label);
+ label = gtk_label_new (_("Random:"));
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_table_attach (GTK_TABLE (table), label, 0, 1, 4, 5,
+ GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
+ gtk_widget_show (label);
+
pressure_options_gui (options, tool_type,
GTK_TABLE (table), 1,
dynamics_labels);
@@ -235,8 +243,11 @@
velocity_options_gui (options, tool_type,
GTK_TABLE (table), 2);
+ direction_options_gui (options, tool_type,
+ GTK_TABLE (table), 3);
+
random_options_gui (options, tool_type,
- GTK_TABLE (table), 3);
+ GTK_TABLE (table), 4);
/* EEK: pack the fixed *after* the buttons so the table calls
* size-allocates on it *before* it places the toggles. Fixes
@@ -540,6 +551,58 @@
}
static void
+direction_options_gui (GimpPaintOptions *paint_options,
+ GType tool_type,
+ GtkTable *table,
+ gint row)
+{
+ GObject *config = G_OBJECT (paint_options);
+ gint column = 1;
+ GtkWidget *scalebutton;
+
+ if (tool_has_opacity_dynamics (tool_type))
+ {
+ dynamics_check_button_new (config, "direction-opacity",
+ table, column++, row);
+ }
+
+ if (tool_has_hardness_dynamics (tool_type))
+ {
+ dynamics_check_button_new (config, "direction-hardness",
+ table, column++, row);
+ }
+
+ if (tool_has_rate_dynamics (tool_type))
+ {
+ dynamics_check_button_new (config, "direction-rate",
+ table, column++, row);
+ }
+
+ if (tool_has_size_dynamics (tool_type))
+ {
+ dynamics_check_button_new (config, "direction-size",
+ table, column++, row);
+ }
+
+ if (tool_has_angle_dynamics (tool_type))
+ {
+ dynamics_check_button_new (config, "direction-angle",
+ table, column++, row);
+ }
+
+ if (tool_has_color_dynamics (tool_type))
+ {
+ dynamics_check_button_new (config, "direction-color",
+ table, column++, row);
+ }
+
+ scalebutton = gimp_prop_scale_button_new (config, "direction-prescale");
+ gtk_table_attach (table, scalebutton, column, column + 1, row, row + 1,
+ GTK_SHRINK, GTK_SHRINK, 0, 0);
+ gtk_widget_show (scalebutton);
+}
+
+static void
random_options_gui (GimpPaintOptions *paint_options,
GType tool_type,
GtkTable *table,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]