gimp r26291 - in trunk: . app/paint app/vectors
- From: neo svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r26291 - in trunk: . app/paint app/vectors
- Date: Wed, 23 Jul 2008 08:30:22 +0000 (UTC)
Author: neo
Date: Wed Jul 23 08:30:22 2008
New Revision: 26291
URL: http://svn.gnome.org/viewvc/gimp?rev=26291&view=rev
Log:
2008-07-23 Sven Neumann <sven gimp org>
Based on a patch from Alexia Death (bug #543706):
* app/paint/gimppaintcore-stroke.[ch]
(gimp_paint_core_stroke_vectors): added code to emulate brush
dynamics by modifying pressure and velocity along the stroke.
* app/vectors/gimpvectors.c (gimp_vectors_stroke): pass the
'emulate-dynamics' parameter to
gimp_paint_core_stroke_vectors().
Modified:
trunk/ChangeLog
trunk/app/paint/gimppaintcore-stroke.c
trunk/app/paint/gimppaintcore-stroke.h
trunk/app/vectors/gimpvectors.c
Modified: trunk/app/paint/gimppaintcore-stroke.c
==============================================================================
--- trunk/app/paint/gimppaintcore-stroke.c (original)
+++ trunk/app/paint/gimppaintcore-stroke.c Wed Jul 23 08:30:22 2008
@@ -34,6 +34,8 @@
#include "gimppaintoptions.h"
+static void gimp_paint_core_stroke_emulate_dynamics (GArray *coords);
+
static const GimpCoords default_coords = GIMP_COORDS_DEFAULT_VALUES;
@@ -219,15 +221,14 @@
gimp_paint_core_stroke_vectors (GimpPaintCore *core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
+ gboolean emulate_dynamics,
GimpVectors *vectors,
GError **error)
{
- GList *stroke;
- GArray *coords = NULL;
- gboolean initialized = FALSE;
- gboolean closed;
- gint off_x, off_y;
- gint vectors_off_x, vectors_off_y;
+ GList *stroke;
+ gboolean initialized = FALSE;
+ gint off_x, off_y;
+ gint vectors_off_x, vectors_off_y;
g_return_val_if_fail (GIMP_IS_PAINT_CORE (core), FALSE);
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
@@ -244,6 +245,9 @@
for (stroke = vectors->strokes; stroke; stroke = stroke->next)
{
+ GArray *coords;
+ gboolean closed;
+
coords = gimp_stroke_interpolate (GIMP_STROKE (stroke->data),
1.0, &closed);
@@ -257,6 +261,9 @@
g_array_index (coords, GimpCoords, i).y -= off_y;
}
+ if (emulate_dynamics)
+ gimp_paint_core_stroke_emulate_dynamics (coords);
+
if (initialized ||
gimp_paint_core_start (core, drawable, paint_options,
&g_array_index (coords, GimpCoords, 0),
@@ -305,3 +312,42 @@
return initialized;
}
+
+static void
+gimp_paint_core_stroke_emulate_dynamics (GArray *coords)
+{
+ const gint pressure_length = coords->len / 3;
+
+ /* Calculate and create pressure ramp parameters */
+ if (pressure_length > 0)
+ {
+ gdouble step = 1.0 / (gdouble) (pressure_length);
+ gint i;
+
+ /* Calculate pressure start ramp */
+ for (i = 0; i < pressure_length; i++)
+ {
+ g_array_index (coords, GimpCoords, i).pressure = i * step;
+ }
+
+ /* Calculate pressure end ramp */
+ for (i = coords->len - pressure_length; i < coords->len; i++)
+ {
+ g_array_index (coords, GimpCoords, i).pressure =
+ 1.0 - (i - (coords->len - pressure_length)) * step;
+ }
+ }
+
+ /* Calculate and create velocity ramp parameters */
+ if (coords->len > 0)
+ {
+ gdouble step = 1.0 / coords->len;
+ gint i;
+
+ /* Calculate velocity end ramp */
+ for (i = 0; i < coords->len; i++)
+ {
+ g_array_index (coords, GimpCoords, i).velocity = i * step;
+ }
+ }
+}
Modified: trunk/app/paint/gimppaintcore-stroke.h
==============================================================================
--- trunk/app/paint/gimppaintcore-stroke.h (original)
+++ trunk/app/paint/gimppaintcore-stroke.h Wed Jul 23 08:30:22 2008
@@ -37,6 +37,7 @@
gboolean gimp_paint_core_stroke_vectors (GimpPaintCore *core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
+ gboolean emulate_dynamics,
GimpVectors *vectors,
GError **error);
Modified: trunk/app/vectors/gimpvectors.c
==============================================================================
--- trunk/app/vectors/gimpvectors.c (original)
+++ trunk/app/vectors/gimpvectors.c Wed Jul 23 08:30:22 2008
@@ -522,6 +522,7 @@
retval = gimp_paint_core_stroke_vectors (core, drawable,
stroke_desc->paint_options,
+ stroke_desc->emulate_dynamics,
vectors, error);
g_object_unref (core);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]