mirror of https://github.com/GNOME/gimp.git
Make dynamics object have an effect on the paintpbrush. Currently pressure and velocity only.
This commit is contained in:
parent
e04a7617d5
commit
db8aa6cb21
|
@ -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
|
||||
|
|
|
@ -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__ */
|
||||
|
|
|
@ -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);*/
|
||||
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 = paint_options->brush_scale;
|
||||
|
||||
core->angle = paint_options->brush_angle;/* gimp_paint_options_get_dynamic_angle (paint_options, coords,
|
||||
paint_core->pixel_dist);*/
|
||||
core->angle = paint_options->brush_angle;
|
||||
|
||||
core->aspect_ratio = paint_options->brush_aspect_ratio;
|
||||
/* gimp_paint_options_get_dynamic_aspect_ratio (paint_options, coords,
|
||||
paint_core->pixel_dist);*/
|
||||
|
||||
if (core->dynamics)
|
||||
{
|
||||
core->scale *= gimp_dynamics_get_output_val(core->dynamics->size_dynamics, *coords);
|
||||
|
||||
core->angle += gimp_dynamics_get_output_val(core->dynamics->angle_dynamics, *coords);
|
||||
|
||||
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 += gimp_dynamics_get_output_val(core->dynamics->angle_dynamics, *coords);
|
||||
|
||||
core->aspect_ratio *= gimp_dynamics_get_output_val(core->dynamics->aspect_ratio_dynamics, *coords);
|
||||
|
||||
}
|
||||
|
||||
core->angle = paint_options->brush_angle; /* gimp_paint_options_get_dynamic_angle (paint_options, coords,
|
||||
paint_core->pixel_dist);*/
|
||||
|
||||
core->aspect_ratio = paint_options->brush_aspect_ratio;/*
|
||||
gimp_paint_options_get_dynamic_aspect_ratio (paint_options, coords,
|
||||
paint_core->pixel_dist);*/
|
||||
}
|
||||
|
||||
core->scale = gimp_brush_core_clamp_brush_scale (core, core->scale);
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue