[gimp/soc-2009-dynamics] Make dynamics object have an effect on the paintpbrush. Currently pressure and velocity only.
- From: Alexia Death <alexiade src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gimp/soc-2009-dynamics] Make dynamics object have an effect on the paintpbrush. Currently pressure and velocity only.
- Date: Thu, 20 Aug 2009 19:47:02 +0000 (UTC)
commit db8aa6cb2131cb7de2743484f4f62fda8834b3fb
Author: Alexia Death <alexiadeath gmail com>
Date: Thu Aug 20 22:46:17 2009 +0300
Make dynamics object have an effect on the paintpbrush. Currently pressure and velocity only.
app/core/gimpdynamics.c | 35 +++++++++++++++++++++++---------
app/core/gimpdynamics.h | 2 +-
app/paint/gimpbrushcore.c | 46 +++++++++++++++++++++++--------------------
app/paint/gimppaintbrush.c | 9 ++-----
4 files changed, 54 insertions(+), 38 deletions(-)
---
diff --git a/app/core/gimpdynamics.c b/app/core/gimpdynamics.c
index c078c07..71a9918 100644
--- a/app/core/gimpdynamics.c
+++ b/app/core/gimpdynamics.c
@@ -158,16 +158,12 @@ static void gimp_dynamics_get_property (GObject *object,
GValue *value,
GParamSpec *pspec);
-static GimpDynamicsOutput* gimp_dynamics_output_init ();
+static GimpDynamicsOutput* gimp_dynamics_output_init (void);
static void gimp_dynamics_output_finalize (GimpDynamicsOutput *dynamics);
-/*
-G_DEFINE_TYPE_WITH_CODE (GimpDynamics, gimp_dynamics, GIMP_TYPE_DATA,
- G_IMPLEMENT_INTERFACE (GIMP_TYPE_DOCKED,
- gimp_dynamics_editor_docked_iface_init))
-*/
+
G_DEFINE_TYPE (GimpDynamics, gimp_dynamics,
GIMP_TYPE_DATA)
@@ -404,7 +400,7 @@ gimp_dynamics_finalize (GObject *object)
}
static GimpDynamicsOutput*
-gimp_dynamics_output_init()
+gimp_dynamics_output_init(void)
{
GimpDynamicsOutput * dynamics = g_slice_new0 (GimpDynamicsOutput);
@@ -903,10 +899,29 @@ gimp_dynamics_get_standard (void)
}
gdouble
-gimp_dynamics_get_output_val (GimpDynamicsOutput *output, GimpCoords *coords)
+gimp_dynamics_get_output_val (GimpDynamicsOutput *output, GimpCoords coords)
{
- printf("Dynamics queried...\n");
- return 1;
+ gdouble total = 0.0;
+ gdouble factors = 0.0;
+
+ gdouble result = 1.0;
+
+ if (output->pressure)
+ {
+ total += coords.pressure;
+ factors++;
+ }
+
+ if (output->velocity)
+ {
+ total += (1.0 - coords.velocity);
+ factors++;
+ }
+ if (factors > 0)
+ result = total / factors;
+
+ //printf("Dynamics queried. Result: %f, vel %f, f: %f, t: %f \n", result, coords.velocity, factors, total);
+ return result;
}
/* Calculates dynamics mix to be used for same parameter
diff --git a/app/core/gimpdynamics.h b/app/core/gimpdynamics.h
index 513e4cc..a1aef1d 100644
--- a/app/core/gimpdynamics.h
+++ b/app/core/gimpdynamics.h
@@ -87,6 +87,6 @@ GimpData * gimp_dynamics_new (const gchar *name);
GimpData * gimp_dynamics_get_standard (void);
-gdouble gimp_dynamics_get_output_val (GimpDynamicsOutput *output, GimpCoords *coords);
+gdouble gimp_dynamics_get_output_val (GimpDynamicsOutput *output, GimpCoords coords);
#endif /* __GIMP_DYNAMICS_OPTIONS_H__ */
diff --git a/app/paint/gimpbrushcore.c b/app/paint/gimpbrushcore.c
index 1dea4c8..a415250 100644
--- a/app/paint/gimpbrushcore.c
+++ b/app/paint/gimpbrushcore.c
@@ -376,9 +376,15 @@ gimp_brush_core_start (GimpPaintCore *paint_core,
{
GimpBrushCore *core = GIMP_BRUSH_CORE (paint_core);
GimpBrush *brush;
-
core->dynamics = gimp_context_get_dynamics (GIMP_CONTEXT (paint_options));
+ /* If context does not have dynamics object for us, lets get standard*/
+ if (!core->dynamics)
+ {
+ core->dynamics = GIMP_DYNAMICS(gimp_dynamics_get_standard());
+ gimp_context_set_dynamics (GIMP_CONTEXT (paint_options), core->dynamics);
+ }
+
brush = gimp_context_get_brush (GIMP_CONTEXT (paint_options));
@@ -394,22 +400,20 @@ gimp_brush_core_start (GimpPaintCore *paint_core,
if (GIMP_BRUSH_CORE_GET_CLASS (core)->handles_transforming_brush)
{
- core->scale = paint_options->brush_scale;/* gimp_paint_options_get_dynamic_size (paint_options, coords,
- TRUE,
- paint_core->pixel_dist);*/
+ core->scale = paint_options->brush_scale;
+
+ core->angle = paint_options->brush_angle;
+
+ core->aspect_ratio = paint_options->brush_aspect_ratio;
+
if (core->dynamics)
{
- core->scale *= gimp_dynamics_get_output_val(core->dynamics->size_dynamics, coords);
- printf("PAss GO 2\n");
- }
- else printf("Go to jail\n");
+ core->scale *= gimp_dynamics_get_output_val(core->dynamics->size_dynamics, *coords);
- core->angle = paint_options->brush_angle;/* gimp_paint_options_get_dynamic_angle (paint_options, coords,
- paint_core->pixel_dist);*/
+ core->angle += gimp_dynamics_get_output_val(core->dynamics->angle_dynamics, *coords);
- core->aspect_ratio = paint_options->brush_aspect_ratio;
-/* gimp_paint_options_get_dynamic_aspect_ratio (paint_options, coords,
- paint_core->pixel_dist);*/
+ core->aspect_ratio *= gimp_dynamics_get_output_val(core->dynamics->aspect_ratio_dynamics, *coords);
+ }
}
core->spacing = (gdouble) gimp_brush_get_spacing (core->main_brush) / 100.0;
@@ -752,18 +756,18 @@ gimp_brush_core_get_paint_area (GimpPaintCore *paint_core,
if (GIMP_BRUSH_CORE_GET_CLASS (core)->handles_transforming_brush)
{
core->scale = paint_options->brush_scale;
+ core->angle = paint_options->brush_angle;
+ core->aspect_ratio = paint_options->brush_aspect_ratio;
+
if (core->dynamics)
{
- core->scale *= gimp_dynamics_get_output_val(core->dynamics->size_dynamics, coords);
- printf("PAssing go1\n");
- }
+ core->scale *= gimp_dynamics_get_output_val(core->dynamics->size_dynamics, *coords);
- core->angle = paint_options->brush_angle; /* gimp_paint_options_get_dynamic_angle (paint_options, coords,
- paint_core->pixel_dist);*/
+ core->angle += gimp_dynamics_get_output_val(core->dynamics->angle_dynamics, *coords);
- core->aspect_ratio = paint_options->brush_aspect_ratio;/*
- gimp_paint_options_get_dynamic_aspect_ratio (paint_options, coords,
- paint_core->pixel_dist);*/
+ core->aspect_ratio *= gimp_dynamics_get_output_val(core->dynamics->aspect_ratio_dynamics, *coords);
+
+ }
}
core->scale = gimp_brush_core_clamp_brush_scale (core, core->scale);
diff --git a/app/paint/gimppaintbrush.c b/app/paint/gimppaintbrush.c
index 1fdf4ce..c23a6f7 100644
--- a/app/paint/gimppaintbrush.c
+++ b/app/paint/gimppaintbrush.c
@@ -131,8 +131,7 @@ _gimp_paintbrush_motion (GimpPaintCore *paint_core,
paint_appl_mode = paint_options->application_mode;
- grad_point = 1;/*gimp_paint_options_get_dynamic_color (paint_options, coords,
- paint_core->pixel_dist);*/
+ grad_point = gimp_dynamics_get_output_val(brush_core->dynamics->color_dynamics, *coords);
/* optionally take the color from the current gradient */
if (gimp_paint_options_get_gradient_color (paint_options, image,
@@ -177,11 +176,9 @@ _gimp_paintbrush_motion (GimpPaintCore *paint_core,
area->bytes);
}
- opacity *= 1;/*gimp_paint_options_get_dynamic_opacity (paint_options, coords,
- paint_core->pixel_dist);*/
+ opacity *= gimp_dynamics_get_output_val(brush_core->dynamics->opacity_dynamics, *coords);
- hardness = 1; /* gimp_paint_options_get_dynamic_hardness (paint_options, coords,
- paint_core->pixel_dist);*/
+ hardness = gimp_dynamics_get_output_val(brush_core->dynamics->hardness_dynamics, *coords);
/* finally, let the brush core paste the colored area on the canvas */
gimp_brush_core_paste_canvas (brush_core, drawable,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]