[gimp] app: Make pressure at stroke ends nicer
- From: Alexia Death <alexiade src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: Make pressure at stroke ends nicer
- Date: Wed, 24 Feb 2010 00:18:38 +0000 (UTC)
commit ede02a68b992483c11e59b28659f37bfe83c7827
Author: Alexia Death <alexiadeath gmail com>
Date: Wed Feb 24 02:09:43 2010 +0200
app: Make pressure at stroke ends nicer
app/display/gimpdisplayshell-callbacks.c | 2 +-
app/display/gimpdisplayshell-coords.c | 19 ++++++++++++++++---
2 files changed, 17 insertions(+), 4 deletions(-)
---
diff --git a/app/display/gimpdisplayshell-callbacks.c b/app/display/gimpdisplayshell-callbacks.c
index b91396c..74289f8 100644
--- a/app/display/gimpdisplayshell-callbacks.c
+++ b/app/display/gimpdisplayshell-callbacks.c
@@ -1083,7 +1083,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
{
if (gimp_tool_control_is_active (active_tool->control))
{
- g_array_append_val (shell->event_queue, image_coords);
+
if (shell->event_queue->len > 0)
gimp_display_shell_flush_event_queue (shell);
diff --git a/app/display/gimpdisplayshell-coords.c b/app/display/gimpdisplayshell-coords.c
index 30dd9fc..a5fa0e5 100644
--- a/app/display/gimpdisplayshell-coords.c
+++ b/app/display/gimpdisplayshell-coords.c
@@ -33,6 +33,9 @@
#define EVENT_FILL_PRECISION 6.0
+#define SMOOTH_FACTOR 0.3
+
+
static void gimp_display_shell_interpolate_stroke (GimpDisplayShell *shell,
GimpCoords *coords);
@@ -79,6 +82,7 @@ gimp_display_shell_eval_event (GimpDisplayShell *shell,
gdouble dir_delta_y = 0.0;
gdouble distance = 1.0;
gboolean event_fill = (inertia_factor > 0);
+ gdouble delta_pressure = 0.0;
/* Smoothing causes problems with cursor tracking
* when zoomed above screen resolution so we need to supress it.
@@ -88,6 +92,18 @@ gimp_display_shell_eval_event (GimpDisplayShell *shell,
inertia_factor = 0.0;
}
+
+ delta_time = (shell->last_motion_delta_time * (1 - SMOOTH_FACTOR)
+ + (time - shell->last_motion_time) * SMOOTH_FACTOR);
+
+ delta_pressure = coords->pressure - shell->last_coords.pressure;
+
+ /* Try to detect a pen lift */
+ if ((delta_time < 50) && (fabs(delta_pressure) > 0.04) && (delta_pressure < 0.0))
+ {
+ return FALSE;
+ }
+
if (shell->last_motion_time == 0)
{
/* First pair is invalid to do any velocity calculation,
@@ -104,8 +120,6 @@ gimp_display_shell_eval_event (GimpDisplayShell *shell,
delta_x = shell->last_coords.x - coords->x;
delta_y = shell->last_coords.y - coords->y;
-#define SMOOTH_FACTOR 0.3
-
/* Events with distances less than the screen resolution are not
* worth handling.
*/
@@ -265,7 +279,6 @@ gimp_display_shell_eval_event (GimpDisplayShell *shell,
}
/* do event fill for devices that do not provide enough events*/
-
if (distance >= EVENT_FILL_PRECISION &&
event_fill &&
shell->event_history->len >= 2)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]