app: add shortcut functions gimp_dynamics_get_foo_value()

and use them for simple use cases instead of dynamics_get_output() and
output_get_foo_value().
This commit is contained in:
Michael Natterer 2012-04-28 11:42:33 +02:00
parent 46ce18f994
commit a3a62b4546
13 changed files with 256 additions and 264 deletions

View File

@ -553,6 +553,57 @@ gimp_dynamics_get_output (GimpDynamics *dynamics,
} }
} }
gdouble
gimp_dynamics_get_linear_value (GimpDynamics *dynamics,
GimpDynamicsOutputType type,
const GimpCoords *coords,
GimpPaintOptions *options,
gdouble fade_point)
{
GimpDynamicsOutput *output;
g_return_val_if_fail (GIMP_IS_DYNAMICS (dynamics), 0.0);
output = gimp_dynamics_get_output (dynamics, type);
return gimp_dynamics_output_get_linear_value (output, coords,
options, fade_point);
}
gdouble
gimp_dynamics_get_angular_value (GimpDynamics *dynamics,
GimpDynamicsOutputType type,
const GimpCoords *coords,
GimpPaintOptions *options,
gdouble fade_point)
{
GimpDynamicsOutput *output;
g_return_val_if_fail (GIMP_IS_DYNAMICS (dynamics), 0.0);
output = gimp_dynamics_get_output (dynamics, type);
return gimp_dynamics_output_get_angular_value (output, coords,
options, fade_point);
}
gdouble
gimp_dynamics_get_aspect_value (GimpDynamics *dynamics,
GimpDynamicsOutputType type,
const GimpCoords *coords,
GimpPaintOptions *options,
gdouble fade_point)
{
GimpDynamicsOutput *output;
g_return_val_if_fail (GIMP_IS_DYNAMICS (dynamics), 0.0);
output = gimp_dynamics_get_output (dynamics, type);
return gimp_dynamics_output_get_aspect_value (output, coords,
options, fade_point);
}
/* private functions */ /* private functions */

View File

@ -52,5 +52,23 @@ GimpData * gimp_dynamics_get_standard (GimpContext *context
GimpDynamicsOutput * gimp_dynamics_get_output (GimpDynamics *dynamics, GimpDynamicsOutput * gimp_dynamics_get_output (GimpDynamics *dynamics,
GimpDynamicsOutputType type); GimpDynamicsOutputType type);
gdouble gimp_dynamics_get_linear_value (GimpDynamics *dynamics,
GimpDynamicsOutputType type,
const GimpCoords *coords,
GimpPaintOptions *options,
gdouble fade_point);
gdouble gimp_dynamics_get_angular_value (GimpDynamics *dynamics,
GimpDynamicsOutputType type,
const GimpCoords *coords,
GimpPaintOptions *options,
gdouble fade_point);
gdouble gimp_dynamics_get_aspect_value (GimpDynamics *dynamics,
GimpDynamicsOutputType type,
const GimpCoords *coords,
GimpPaintOptions *options,
gdouble fade_point);
#endif /* __GIMP_DYNAMICS_H__ */ #endif /* __GIMP_DYNAMICS_H__ */

View File

@ -28,7 +28,6 @@
#include "core/gimpbrush.h" #include "core/gimpbrush.h"
#include "core/gimpdrawable.h" #include "core/gimpdrawable.h"
#include "core/gimpdynamics.h" #include "core/gimpdynamics.h"
#include "core/gimpdynamicsoutput.h"
#include "core/gimpgradient.h" #include "core/gimpgradient.h"
#include "core/gimpimage.h" #include "core/gimpimage.h"
@ -139,11 +138,10 @@ gimp_airbrush_paint (GimpPaintCore *paint_core,
if ((options->rate != 0.0) && (!options->motion_only)) if ((options->rate != 0.0) && (!options->motion_only))
{ {
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable)); GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
GimpDynamicsOutput *rate_output; gdouble fade_point;
gdouble fade_point; gdouble dynamic_rate;
gdouble dynamic_rate; gint timeout;
gint timeout;
fade_point = gimp_paint_options_get_fade (paint_options, image, fade_point = gimp_paint_options_get_fade (paint_options, image,
paint_core->pixel_dist); paint_core->pixel_dist);
@ -151,13 +149,11 @@ gimp_airbrush_paint (GimpPaintCore *paint_core,
airbrush->drawable = drawable; airbrush->drawable = drawable;
airbrush->paint_options = paint_options; airbrush->paint_options = paint_options;
rate_output = gimp_dynamics_get_output (dynamics, dynamic_rate = gimp_dynamics_get_linear_value (dynamics,
GIMP_DYNAMICS_OUTPUT_RATE); GIMP_DYNAMICS_OUTPUT_RATE,
coords,
dynamic_rate = gimp_dynamics_output_get_linear_value (rate_output, paint_options,
coords, fade_point);
paint_options,
fade_point);
timeout = 10000 / (options->rate * dynamic_rate); timeout = 10000 / (options->rate * dynamic_rate);
@ -189,23 +185,21 @@ gimp_airbrush_motion (GimpPaintCore *paint_core,
const GimpCoords *coords) const GimpCoords *coords)
{ {
GimpAirbrushOptions *options = GIMP_AIRBRUSH_OPTIONS (paint_options); GimpAirbrushOptions *options = GIMP_AIRBRUSH_OPTIONS (paint_options);
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable)); GimpDynamics *dynamics = GIMP_BRUSH_CORE (paint_core)->dynamics;
GimpDynamicsOutput *flow_output; GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
gdouble opacity; gdouble opacity;
gdouble fade_point; gdouble fade_point;
flow_output = gimp_dynamics_get_output (GIMP_BRUSH_CORE (paint_core)->dynamics,
GIMP_DYNAMICS_OUTPUT_FLOW);
fade_point = gimp_paint_options_get_fade (paint_options, image, fade_point = gimp_paint_options_get_fade (paint_options, image,
paint_core->pixel_dist); paint_core->pixel_dist);
opacity = (options->flow / 100.0 * opacity = (options->flow / 100.0 *
gimp_dynamics_output_get_linear_value (flow_output, gimp_dynamics_get_linear_value (dynamics,
coords, GIMP_DYNAMICS_OUTPUT_FLOW,
paint_options, coords,
fade_point)); paint_options,
fade_point));
_gimp_paintbrush_motion (paint_core, drawable, paint_options, coords, opacity); _gimp_paintbrush_motion (paint_core, drawable, paint_options, coords, opacity);
} }

View File

@ -228,7 +228,6 @@ gimp_brush_core_init (GimpBrushCore *core)
core->subsample_brushes[i][j] = NULL; core->subsample_brushes[i][j] = NULL;
} }
} }
} }
static void static void
@ -323,21 +322,17 @@ gimp_brush_core_pre_paint (GimpPaintCore *paint_core,
if (GIMP_BRUSH_CORE_GET_CLASS (core)->handles_dynamic_transforming_brush) if (GIMP_BRUSH_CORE_GET_CLASS (core)->handles_dynamic_transforming_brush)
{ {
GimpDynamicsOutput *size_output;
size_output = gimp_dynamics_get_output (core->dynamics,
GIMP_DYNAMICS_OUTPUT_SIZE);
fade_point = gimp_paint_options_get_fade (paint_options, image, fade_point = gimp_paint_options_get_fade (paint_options, image,
paint_core->pixel_dist); paint_core->pixel_dist);
scale = paint_options->brush_size / scale = paint_options->brush_size /
MAX (gimp_temp_buf_get_width (core->main_brush->mask), MAX (gimp_temp_buf_get_width (core->main_brush->mask),
gimp_temp_buf_get_height (core->main_brush->mask)) * gimp_temp_buf_get_height (core->main_brush->mask)) *
gimp_dynamics_output_get_linear_value (size_output, gimp_dynamics_get_linear_value (core->dynamics,
&current_coords, GIMP_DYNAMICS_OUTPUT_SIZE,
paint_options, &current_coords,
fade_point); paint_options,
fade_point);
if (scale < 0.0000001) if (scale < 0.0000001)
return FALSE; return FALSE;
@ -735,19 +730,16 @@ gimp_brush_core_interpolate (GimpPaintCore *paint_core,
if (core->jitter > 0.0) if (core->jitter > 0.0)
{ {
GimpDynamicsOutput *jitter_output; gdouble dyn_jitter;
gdouble dyn_jitter; gdouble jitter_dist;
gdouble jitter_dist; gint32 jitter_angle;
gint32 jitter_angle;
jitter_output = gimp_dynamics_get_output (core->dynamics,
GIMP_DYNAMICS_OUTPUT_JITTER);
dyn_jitter = (core->jitter * dyn_jitter = (core->jitter *
gimp_dynamics_output_get_linear_value (jitter_output, gimp_dynamics_get_linear_value (core->dynamics,
&current_coords, GIMP_DYNAMICS_OUTPUT_JITTER,
paint_options, &current_coords,
fade_point)); paint_options,
fade_point));
jitter_dist = g_rand_double_range (core->rand, 0, dyn_jitter); jitter_dist = g_rand_double_range (core->rand, 0, dyn_jitter);
jitter_angle = g_rand_int_range (core->rand, jitter_angle = g_rand_int_range (core->rand,
@ -769,7 +761,6 @@ gimp_brush_core_interpolate (GimpPaintCore *paint_core,
gimp_paint_core_paint (paint_core, drawable, paint_options, gimp_paint_core_paint (paint_core, drawable, paint_options,
GIMP_PAINT_STATE_MOTION, time); GIMP_PAINT_STATE_MOTION, time);
} }
current_coords.x = last_coords.x + delta_vec.x; current_coords.x = last_coords.x + delta_vec.x;
@ -1319,7 +1310,6 @@ gimp_brush_core_solidify_mask (GimpBrushCore *core,
gint dest_offset_y = 0; gint dest_offset_y = 0;
gint brush_mask_width = gimp_temp_buf_get_width (brush_mask); gint brush_mask_width = gimp_temp_buf_get_width (brush_mask);
gint brush_mask_height = gimp_temp_buf_get_height (brush_mask); gint brush_mask_height = gimp_temp_buf_get_height (brush_mask);
gint i, j; gint i, j;
if ((brush_mask_width % 2) == 0) if ((brush_mask_width % 2) == 0)
@ -1504,26 +1494,23 @@ gimp_brush_core_eval_transform_dynamics (GimpBrushCore *core,
paint_core->pixel_dist); paint_core->pixel_dist);
} }
output = gimp_dynamics_get_output (core->dynamics, core->scale *= gimp_dynamics_get_linear_value (core->dynamics,
GIMP_DYNAMICS_OUTPUT_SIZE); GIMP_DYNAMICS_OUTPUT_SIZE,
core->scale *= gimp_dynamics_output_get_linear_value (output, coords,
coords, paint_options,
paint_options, fade_point);
fade_point);
output = gimp_dynamics_get_output (core->dynamics, core->angle += gimp_dynamics_get_angular_value (core->dynamics,
GIMP_DYNAMICS_OUTPUT_ANGLE); GIMP_DYNAMICS_OUTPUT_ANGLE,
core->angle += gimp_dynamics_output_get_angular_value (output, coords,
coords, paint_options,
paint_options, fade_point);
fade_point);
output = gimp_dynamics_get_output (core->dynamics, core->hardness = gimp_dynamics_get_linear_value (core->dynamics,
GIMP_DYNAMICS_OUTPUT_HARDNESS); GIMP_DYNAMICS_OUTPUT_HARDNESS,
core->hardness = gimp_dynamics_output_get_linear_value (output, coords,
coords, paint_options,
paint_options, fade_point);
fade_point);
output = gimp_dynamics_get_output (core->dynamics, output = gimp_dynamics_get_output (core->dynamics,
GIMP_DYNAMICS_OUTPUT_ASPECT_RATIO); GIMP_DYNAMICS_OUTPUT_ASPECT_RATIO);
@ -1699,7 +1686,7 @@ gimp_brush_core_paint_line_pixmap_mask (GimpDrawable *drawable,
fish = babl_fish (pixmap_format, fish = babl_fish (pixmap_format,
gimp_drawable_get_format_with_alpha (drawable)); gimp_drawable_get_format_with_alpha (drawable));
/* put the source pixmap's pixels, into one line, so we can use /* put the source pixmap's pixels into one line, so we can use
* one single call to babl_process() to convert the entire line * one single call to babl_process() to convert the entire line
*/ */
for (i = 0; i < width; i++) for (i = 0; i < width; i++)

View File

@ -31,7 +31,6 @@
#include "core/gimp.h" #include "core/gimp.h"
#include "core/gimpdrawable.h" #include "core/gimpdrawable.h"
#include "core/gimpdynamics.h" #include "core/gimpdynamics.h"
#include "core/gimpdynamicsoutput.h"
#include "core/gimperror.h" #include "core/gimperror.h"
#include "core/gimpimage.h" #include "core/gimpimage.h"
#include "core/gimppattern.h" #include "core/gimppattern.h"
@ -149,14 +148,13 @@ gimp_clone_motion (GimpSourceCore *source_core,
gint paint_area_width, gint paint_area_width,
gint paint_area_height) gint paint_area_height)
{ {
GimpPaintCore *paint_core = GIMP_PAINT_CORE (source_core); GimpPaintCore *paint_core = GIMP_PAINT_CORE (source_core);
GimpCloneOptions *options = GIMP_CLONE_OPTIONS (paint_options); GimpCloneOptions *options = GIMP_CLONE_OPTIONS (paint_options);
GimpSourceOptions *source_options = GIMP_SOURCE_OPTIONS (paint_options); GimpSourceOptions *source_options = GIMP_SOURCE_OPTIONS (paint_options);
GimpContext *context = GIMP_CONTEXT (paint_options); GimpContext *context = GIMP_CONTEXT (paint_options);
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable)); GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
GimpDynamicsOutput *force_output; gdouble fade_point;
gdouble fade_point; gdouble force;
gdouble force;
switch (options->clone_type) switch (options->clone_type)
{ {
@ -195,16 +193,14 @@ gimp_clone_motion (GimpSourceCore *source_core,
break; break;
} }
force_output = gimp_dynamics_get_output (GIMP_BRUSH_CORE (paint_core)->dynamics,
GIMP_DYNAMICS_OUTPUT_FORCE);
fade_point = gimp_paint_options_get_fade (paint_options, image, fade_point = gimp_paint_options_get_fade (paint_options, image,
paint_core->pixel_dist); paint_core->pixel_dist);
force = gimp_dynamics_output_get_linear_value (force_output, force = gimp_dynamics_get_linear_value (GIMP_BRUSH_CORE (paint_core)->dynamics,
coords, GIMP_DYNAMICS_OUTPUT_FORCE,
paint_options, coords,
fade_point); paint_options,
fade_point);
gimp_brush_core_paste_canvas (GIMP_BRUSH_CORE (paint_core), drawable, gimp_brush_core_paste_canvas (GIMP_BRUSH_CORE (paint_core), drawable,
coords, coords,

View File

@ -28,7 +28,6 @@
#include "core/gimpbrush.h" #include "core/gimpbrush.h"
#include "core/gimpdrawable.h" #include "core/gimpdrawable.h"
#include "core/gimpdynamics.h" #include "core/gimpdynamics.h"
#include "core/gimpdynamicsoutput.h"
#include "core/gimpimage.h" #include "core/gimpimage.h"
#include "core/gimppickable.h" #include "core/gimppickable.h"
#include "core/gimptempbuf.h" #include "core/gimptempbuf.h"
@ -129,8 +128,6 @@ gimp_convolve_motion (GimpPaintCore *paint_core,
GimpConvolveOptions *options = GIMP_CONVOLVE_OPTIONS (paint_options); GimpConvolveOptions *options = GIMP_CONVOLVE_OPTIONS (paint_options);
GimpContext *context = GIMP_CONTEXT (paint_options); GimpContext *context = GIMP_CONTEXT (paint_options);
GimpDynamics *dynamics = GIMP_BRUSH_CORE (paint_core)->dynamics; GimpDynamics *dynamics = GIMP_BRUSH_CORE (paint_core)->dynamics;
GimpDynamicsOutput *opacity_output;
GimpDynamicsOutput *rate_output;
GimpImage *image; GimpImage *image;
GeglBuffer *paint_buffer; GeglBuffer *paint_buffer;
gint paint_buffer_x; gint paint_buffer_x;
@ -143,16 +140,14 @@ gimp_convolve_motion (GimpPaintCore *paint_core,
image = gimp_item_get_image (GIMP_ITEM (drawable)); image = gimp_item_get_image (GIMP_ITEM (drawable));
opacity_output = gimp_dynamics_get_output (dynamics,
GIMP_DYNAMICS_OUTPUT_OPACITY);
fade_point = gimp_paint_options_get_fade (paint_options, image, fade_point = gimp_paint_options_get_fade (paint_options, image,
paint_core->pixel_dist); paint_core->pixel_dist);
opacity = gimp_dynamics_output_get_linear_value (opacity_output, opacity = gimp_dynamics_get_linear_value (dynamics,
coords, GIMP_DYNAMICS_OUTPUT_OPACITY,
paint_options, coords,
fade_point); paint_options,
fade_point);
if (opacity == 0.0) if (opacity == 0.0)
return; return;
@ -163,14 +158,12 @@ gimp_convolve_motion (GimpPaintCore *paint_core,
if (! paint_buffer) if (! paint_buffer)
return; return;
rate_output = gimp_dynamics_get_output (dynamics,
GIMP_DYNAMICS_OUTPUT_RATE);
rate = (options->rate * rate = (options->rate *
gimp_dynamics_output_get_linear_value (rate_output, gimp_dynamics_get_linear_value (dynamics,
coords, GIMP_DYNAMICS_OUTPUT_RATE,
paint_options, coords,
fade_point)); paint_options,
fade_point));
gimp_convolve_calculate_matrix (convolve, options->type, gimp_convolve_calculate_matrix (convolve, options->type,
gimp_temp_buf_get_width (brush_core->brush->mask) / 2, gimp_temp_buf_get_width (brush_core->brush->mask) / 2,

View File

@ -30,7 +30,6 @@
#include "core/gimp.h" #include "core/gimp.h"
#include "core/gimpdrawable.h" #include "core/gimpdrawable.h"
#include "core/gimpdynamics.h" #include "core/gimpdynamics.h"
#include "core/gimpdynamicsoutput.h"
#include "core/gimpimage.h" #include "core/gimpimage.h"
#include "gimpdodgeburn.h" #include "gimpdodgeburn.h"
@ -115,9 +114,7 @@ gimp_dodge_burn_motion (GimpPaintCore *paint_core,
GimpDodgeBurnOptions *options = GIMP_DODGE_BURN_OPTIONS (paint_options); GimpDodgeBurnOptions *options = GIMP_DODGE_BURN_OPTIONS (paint_options);
GimpContext *context = GIMP_CONTEXT (paint_options); GimpContext *context = GIMP_CONTEXT (paint_options);
GimpDynamics *dynamics = GIMP_BRUSH_CORE (paint_core)->dynamics; GimpDynamics *dynamics = GIMP_BRUSH_CORE (paint_core)->dynamics;
GimpDynamicsOutput *opacity_output; GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
GimpDynamicsOutput *hardness_output;
GimpImage *image;
GeglBuffer *paint_buffer; GeglBuffer *paint_buffer;
gint paint_buffer_x; gint paint_buffer_x;
gint paint_buffer_y; gint paint_buffer_y;
@ -125,18 +122,14 @@ gimp_dodge_burn_motion (GimpPaintCore *paint_core,
gdouble opacity; gdouble opacity;
gdouble hardness; gdouble hardness;
image = gimp_item_get_image (GIMP_ITEM (drawable));
opacity_output = gimp_dynamics_get_output (dynamics,
GIMP_DYNAMICS_OUTPUT_OPACITY);
fade_point = gimp_paint_options_get_fade (paint_options, image, fade_point = gimp_paint_options_get_fade (paint_options, image,
paint_core->pixel_dist); paint_core->pixel_dist);
opacity = gimp_dynamics_output_get_linear_value (opacity_output, opacity = gimp_dynamics_get_linear_value (dynamics,
coords, GIMP_DYNAMICS_OUTPUT_OPACITY,
paint_options, coords,
fade_point); paint_options,
fade_point);
if (opacity == 0.0) if (opacity == 0.0)
return; return;
@ -159,13 +152,11 @@ gimp_dodge_burn_motion (GimpPaintCore *paint_core,
options->type, options->type,
options->mode); options->mode);
hardness_output = gimp_dynamics_get_output (dynamics, hardness = gimp_dynamics_get_linear_value (dynamics,
GIMP_DYNAMICS_OUTPUT_HARDNESS); GIMP_DYNAMICS_OUTPUT_HARDNESS,
coords,
hardness = gimp_dynamics_output_get_linear_value (hardness_output, paint_options,
coords, fade_point);
paint_options,
fade_point);
/* Replace the newly dodgedburned area (paint_area) to the image */ /* Replace the newly dodgedburned area (paint_area) to the image */
gimp_brush_core_replace_canvas (GIMP_BRUSH_CORE (paint_core), drawable, gimp_brush_core_replace_canvas (GIMP_BRUSH_CORE (paint_core), drawable,

View File

@ -26,7 +26,6 @@
#include "core/gimp.h" #include "core/gimp.h"
#include "core/gimpdrawable.h" #include "core/gimpdrawable.h"
#include "core/gimpdynamics.h" #include "core/gimpdynamics.h"
#include "core/gimpdynamicsoutput.h"
#include "core/gimpimage.h" #include "core/gimpimage.h"
#include "gimperaser.h" #include "gimperaser.h"
@ -103,31 +102,27 @@ gimp_eraser_motion (GimpPaintCore *paint_core,
GimpPaintOptions *paint_options, GimpPaintOptions *paint_options,
const GimpCoords *coords) const GimpCoords *coords)
{ {
GimpEraserOptions *options = GIMP_ERASER_OPTIONS (paint_options); GimpEraserOptions *options = GIMP_ERASER_OPTIONS (paint_options);
GimpContext *context = GIMP_CONTEXT (paint_options); GimpContext *context = GIMP_CONTEXT (paint_options);
GimpDynamics *dynamics = GIMP_BRUSH_CORE (paint_core)->dynamics; GimpDynamics *dynamics = GIMP_BRUSH_CORE (paint_core)->dynamics;
GimpDynamicsOutput *opacity_output; GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
GimpDynamicsOutput *force_output; gdouble fade_point;
gdouble fade_point; gdouble opacity;
gdouble opacity; GeglBuffer *paint_buffer;
GeglBuffer *paint_buffer; gint paint_buffer_x;
gint paint_buffer_x; gint paint_buffer_y;
gint paint_buffer_y; GimpRGB background;
GimpRGB background; GeglColor *color;
GeglColor *color; gdouble force;
gdouble force;
opacity_output = gimp_dynamics_get_output (dynamics, fade_point = gimp_paint_options_get_fade (paint_options, image,
GIMP_DYNAMICS_OUTPUT_OPACITY);
fade_point = gimp_paint_options_get_fade (paint_options,
gimp_item_get_image (GIMP_ITEM (drawable)),
paint_core->pixel_dist); paint_core->pixel_dist);
opacity = gimp_dynamics_output_get_linear_value (opacity_output, opacity = gimp_dynamics_get_linear_value (dynamics,
coords, GIMP_DYNAMICS_OUTPUT_OPACITY,
paint_options, coords,
fade_point); paint_options,
fade_point);
if (opacity == 0.0) if (opacity == 0.0)
return; return;
@ -144,13 +139,11 @@ gimp_eraser_motion (GimpPaintCore *paint_core,
gegl_buffer_set_color (paint_buffer, NULL, color); gegl_buffer_set_color (paint_buffer, NULL, color);
g_object_unref (color); g_object_unref (color);
force_output = gimp_dynamics_get_output (dynamics, force = gimp_dynamics_get_linear_value (dynamics,
GIMP_DYNAMICS_OUTPUT_FORCE); GIMP_DYNAMICS_OUTPUT_FORCE,
coords,
force = gimp_dynamics_output_get_linear_value (force_output, paint_options,
coords, fade_point);
paint_options,
fade_point);
gimp_brush_core_paste_canvas (GIMP_BRUSH_CORE (paint_core), drawable, gimp_brush_core_paste_canvas (GIMP_BRUSH_CORE (paint_core), drawable,
coords, coords,

View File

@ -31,7 +31,6 @@
#include "core/gimpbrush.h" #include "core/gimpbrush.h"
#include "core/gimpdrawable.h" #include "core/gimpdrawable.h"
#include "core/gimpdynamics.h" #include "core/gimpdynamics.h"
#include "core/gimpdynamicsoutput.h"
#include "core/gimperror.h" #include "core/gimperror.h"
#include "core/gimpimage.h" #include "core/gimpimage.h"
#include "core/gimppickable.h" #include "core/gimppickable.h"
@ -475,27 +474,24 @@ gimp_heal_motion (GimpSourceCore *source_core,
gint paint_area_width, gint paint_area_width,
gint paint_area_height) gint paint_area_height)
{ {
GimpPaintCore *paint_core = GIMP_PAINT_CORE (source_core); GimpPaintCore *paint_core = GIMP_PAINT_CORE (source_core);
GimpContext *context = GIMP_CONTEXT (paint_options); GimpContext *context = GIMP_CONTEXT (paint_options);
GimpDynamics *dynamics = GIMP_BRUSH_CORE (paint_core)->dynamics; GimpDynamics *dynamics = GIMP_BRUSH_CORE (paint_core)->dynamics;
GimpDynamicsOutput *hardness_output; GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable)); GeglBuffer *src_copy;
GeglBuffer *src_copy; GeglBuffer *mask_buffer;
GeglBuffer *mask_buffer; const GimpTempBuf *mask_buf;
const GimpTempBuf *mask_buf; gdouble fade_point;
gdouble fade_point; gdouble hardness;
gdouble hardness;
hardness_output = gimp_dynamics_get_output (dynamics,
GIMP_DYNAMICS_OUTPUT_HARDNESS);
fade_point = gimp_paint_options_get_fade (paint_options, image, fade_point = gimp_paint_options_get_fade (paint_options, image,
paint_core->pixel_dist); paint_core->pixel_dist);
hardness = gimp_dynamics_output_get_linear_value (hardness_output, hardness = gimp_dynamics_get_linear_value (dynamics,
coords, GIMP_DYNAMICS_OUTPUT_HARDNESS,
paint_options, coords,
fade_point); paint_options,
fade_point);
mask_buf = gimp_brush_core_get_brush_mask (GIMP_BRUSH_CORE (source_core), mask_buf = gimp_brush_core_get_brush_mask (GIMP_BRUSH_CORE (source_core),
coords, coords,

View File

@ -32,7 +32,6 @@
#include "core/gimpbrush.h" #include "core/gimpbrush.h"
#include "core/gimpdrawable.h" #include "core/gimpdrawable.h"
#include "core/gimpdynamics.h" #include "core/gimpdynamics.h"
#include "core/gimpdynamicsoutput.h"
#include "core/gimpgradient.h" #include "core/gimpgradient.h"
#include "core/gimpimage.h" #include "core/gimpimage.h"
#include "core/gimptempbuf.h" #include "core/gimptempbuf.h"
@ -112,9 +111,6 @@ _gimp_paintbrush_motion (GimpPaintCore *paint_core,
GimpBrushCore *brush_core = GIMP_BRUSH_CORE (paint_core); GimpBrushCore *brush_core = GIMP_BRUSH_CORE (paint_core);
GimpContext *context = GIMP_CONTEXT (paint_options); GimpContext *context = GIMP_CONTEXT (paint_options);
GimpDynamics *dynamics = brush_core->dynamics; GimpDynamics *dynamics = brush_core->dynamics;
GimpDynamicsOutput *opacity_output;
GimpDynamicsOutput *color_output;
GimpDynamicsOutput *force_output;
GimpImage *image; GimpImage *image;
GimpRGB gradient_color; GimpRGB gradient_color;
GeglBuffer *paint_buffer; GeglBuffer *paint_buffer;
@ -127,16 +123,14 @@ _gimp_paintbrush_motion (GimpPaintCore *paint_core,
image = gimp_item_get_image (GIMP_ITEM (drawable)); image = gimp_item_get_image (GIMP_ITEM (drawable));
opacity_output = gimp_dynamics_get_output (dynamics,
GIMP_DYNAMICS_OUTPUT_OPACITY);
fade_point = gimp_paint_options_get_fade (paint_options, image, fade_point = gimp_paint_options_get_fade (paint_options, image,
paint_core->pixel_dist); paint_core->pixel_dist);
opacity *= gimp_dynamics_output_get_linear_value (opacity_output, opacity *= gimp_dynamics_get_linear_value (dynamics,
coords, GIMP_DYNAMICS_OUTPUT_OPACITY,
paint_options, coords,
fade_point); paint_options,
fade_point);
if (opacity == 0.0) if (opacity == 0.0)
return; return;
@ -149,13 +143,11 @@ _gimp_paintbrush_motion (GimpPaintCore *paint_core,
paint_appl_mode = paint_options->application_mode; paint_appl_mode = paint_options->application_mode;
color_output = gimp_dynamics_get_output (dynamics, grad_point = gimp_dynamics_get_linear_value (dynamics,
GIMP_DYNAMICS_OUTPUT_COLOR); GIMP_DYNAMICS_OUTPUT_COLOR,
coords,
grad_point = gimp_dynamics_output_get_linear_value (color_output, paint_options,
coords, fade_point);
paint_options,
fade_point);
if (gimp_paint_options_get_gradient_color (paint_options, image, if (gimp_paint_options_get_gradient_color (paint_options, image,
grad_point, grad_point,
@ -204,13 +196,11 @@ _gimp_paintbrush_motion (GimpPaintCore *paint_core,
g_object_unref (color); g_object_unref (color);
} }
force_output = gimp_dynamics_get_output (dynamics, force = gimp_dynamics_get_linear_value (dynamics,
GIMP_DYNAMICS_OUTPUT_FORCE); GIMP_DYNAMICS_OUTPUT_FORCE,
coords,
force = gimp_dynamics_output_get_linear_value (force_output, paint_options,
coords, fade_point);
paint_options,
fade_point);
/* finally, let the brush core paste the colored area on the canvas */ /* finally, let the brush core paste the colored area on the canvas */
gimp_brush_core_paste_canvas (brush_core, drawable, gimp_brush_core_paste_canvas (brush_core, drawable,

View File

@ -911,7 +911,8 @@ gimp_paint_core_smooth_coords (GimpPaintCore *core,
{ {
/* We use gaussian function with velocity as a window function */ /* We use gaussian function with velocity as a window function */
velocity_sum += next_coords->velocity * 100; velocity_sum += next_coords->velocity * 100;
rate = gaussian_weight * exp (-velocity_sum*velocity_sum / (2 * gaussian_weight2)); rate = gaussian_weight * exp (-velocity_sum * velocity_sum /
(2 * gaussian_weight2));
} }
scale_sum += rate; scale_sum += rate;
@ -924,7 +925,5 @@ gimp_paint_core_smooth_coords (GimpPaintCore *core,
coords->x /= scale_sum; coords->x /= scale_sum;
coords->y /= scale_sum; coords->y /= scale_sum;
} }
} }
} }

View File

@ -29,7 +29,6 @@
#include "core/gimpbrush.h" #include "core/gimpbrush.h"
#include "core/gimpdrawable.h" #include "core/gimpdrawable.h"
#include "core/gimpdynamics.h" #include "core/gimpdynamics.h"
#include "core/gimpdynamicsoutput.h"
#include "core/gimpimage.h" #include "core/gimpimage.h"
#include "core/gimppickable.h" #include "core/gimppickable.h"
#include "core/gimptempbuf.h" #include "core/gimptempbuf.h"
@ -232,38 +231,31 @@ gimp_smudge_motion (GimpPaintCore *paint_core,
GimpPaintOptions *paint_options, GimpPaintOptions *paint_options,
const GimpCoords *coords) const GimpCoords *coords)
{ {
GimpSmudge *smudge = GIMP_SMUDGE (paint_core); GimpSmudge *smudge = GIMP_SMUDGE (paint_core);
GimpSmudgeOptions *options = GIMP_SMUDGE_OPTIONS (paint_options); GimpSmudgeOptions *options = GIMP_SMUDGE_OPTIONS (paint_options);
GimpContext *context = GIMP_CONTEXT (paint_options); GimpContext *context = GIMP_CONTEXT (paint_options);
GimpDynamics *dynamics = GIMP_BRUSH_CORE (paint_core)->dynamics; GimpDynamics *dynamics = GIMP_BRUSH_CORE (paint_core)->dynamics;
GimpDynamicsOutput *opacity_output; GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
GimpDynamicsOutput *rate_output; GeglBuffer *paint_buffer;
GimpDynamicsOutput *hardness_output; gint paint_buffer_x;
GimpImage *image; gint paint_buffer_y;
GeglBuffer *paint_buffer; gint paint_buffer_width;
gint paint_buffer_x; gint paint_buffer_height;
gint paint_buffer_y; gdouble fade_point;
gint paint_buffer_width; gdouble opacity;
gint paint_buffer_height; gdouble rate;
gdouble fade_point; gdouble dynamic_rate;
gdouble opacity; gint x, y;
gdouble rate; gdouble hardness;
gdouble dynamic_rate;
gint x, y;
gdouble hardness;
image = gimp_item_get_image (GIMP_ITEM (drawable));
opacity_output = gimp_dynamics_get_output (dynamics,
GIMP_DYNAMICS_OUTPUT_OPACITY);
fade_point = gimp_paint_options_get_fade (paint_options, image, fade_point = gimp_paint_options_get_fade (paint_options, image,
paint_core->pixel_dist); paint_core->pixel_dist);
opacity = gimp_dynamics_output_get_linear_value (opacity_output, opacity = gimp_dynamics_get_linear_value (dynamics,
coords, GIMP_DYNAMICS_OUTPUT_OPACITY,
paint_options, coords,
fade_point); paint_options,
fade_point);
if (opacity == 0.0) if (opacity == 0.0)
return; return;
@ -281,13 +273,11 @@ gimp_smudge_motion (GimpPaintCore *paint_core,
gimp_smudge_accumulator_coords (paint_core, coords, &x, &y); gimp_smudge_accumulator_coords (paint_core, coords, &x, &y);
/* Enable dynamic rate */ /* Enable dynamic rate */
rate_output = gimp_dynamics_get_output (dynamics, dynamic_rate = gimp_dynamics_get_linear_value (dynamics,
GIMP_DYNAMICS_OUTPUT_RATE); GIMP_DYNAMICS_OUTPUT_RATE,
coords,
dynamic_rate = gimp_dynamics_output_get_linear_value (rate_output, paint_options,
coords, fade_point);
paint_options,
fade_point);
rate = (options->rate / 100.0) * dynamic_rate; rate = (options->rate / 100.0) * dynamic_rate;
@ -324,13 +314,11 @@ gimp_smudge_motion (GimpPaintCore *paint_core,
paint_buffer, paint_buffer,
GEGL_RECTANGLE (0, 0, 0, 0)); GEGL_RECTANGLE (0, 0, 0, 0));
hardness_output = gimp_dynamics_get_output (dynamics, hardness = gimp_dynamics_get_linear_value (dynamics,
GIMP_DYNAMICS_OUTPUT_HARDNESS); GIMP_DYNAMICS_OUTPUT_HARDNESS,
coords,
hardness = gimp_dynamics_output_get_linear_value (hardness_output, paint_options,
coords, fade_point);
paint_options,
fade_point);
gimp_brush_core_replace_canvas (GIMP_BRUSH_CORE (paint_core), drawable, gimp_brush_core_replace_canvas (GIMP_BRUSH_CORE (paint_core), drawable,
coords, coords,

View File

@ -28,7 +28,6 @@
#include "core/gimp.h" #include "core/gimp.h"
#include "core/gimpdrawable.h" #include "core/gimpdrawable.h"
#include "core/gimpdynamics.h" #include "core/gimpdynamics.h"
#include "core/gimpdynamicsoutput.h"
#include "core/gimperror.h" #include "core/gimperror.h"
#include "core/gimpimage.h" #include "core/gimpimage.h"
#include "core/gimppickable.h" #include "core/gimppickable.h"
@ -346,36 +345,33 @@ gimp_source_core_motion (GimpSourceCore *source_core,
const GimpCoords *coords) const GimpCoords *coords)
{ {
GimpPaintCore *paint_core = GIMP_PAINT_CORE (source_core); GimpPaintCore *paint_core = GIMP_PAINT_CORE (source_core);
GimpSourceOptions *options = GIMP_SOURCE_OPTIONS (paint_options); GimpSourceOptions *options = GIMP_SOURCE_OPTIONS (paint_options);
GimpDynamics *dynamics = GIMP_BRUSH_CORE (paint_core)->dynamics; GimpDynamics *dynamics = GIMP_BRUSH_CORE (paint_core)->dynamics;
GimpDynamicsOutput *opacity_output; GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable)); GimpPickable *src_pickable = NULL;
GimpPickable *src_pickable = NULL; GeglBuffer *src_buffer = NULL;
GeglBuffer *src_buffer = NULL; GeglRectangle src_rect;
GeglRectangle src_rect; gint src_offset_x;
gint src_offset_x; gint src_offset_y;
gint src_offset_y; GeglBuffer *paint_buffer;
GeglBuffer *paint_buffer; gint paint_buffer_x;
gint paint_buffer_x; gint paint_buffer_y;
gint paint_buffer_y; gint paint_area_offset_x;
gint paint_area_offset_x; gint paint_area_offset_y;
gint paint_area_offset_y; gint paint_area_width;
gint paint_area_width; gint paint_area_height;
gint paint_area_height; gdouble fade_point;
gdouble fade_point; gdouble opacity;
gdouble opacity;
opacity_output = gimp_dynamics_get_output (dynamics,
GIMP_DYNAMICS_OUTPUT_OPACITY);
fade_point = gimp_paint_options_get_fade (paint_options, image, fade_point = gimp_paint_options_get_fade (paint_options, image,
paint_core->pixel_dist); paint_core->pixel_dist);
opacity = gimp_dynamics_output_get_linear_value (opacity_output, opacity = gimp_dynamics_get_linear_value (dynamics,
coords, GIMP_DYNAMICS_OUTPUT_OPACITY,
paint_options, coords,
fade_point); paint_options,
fade_point);
if (opacity == 0.0) if (opacity == 0.0)
return; return;