Commit 7609e3d8 authored by Alexia Death's avatar Alexia Death

app: Fix direction in path stroking

parent e23e99e2
...@@ -376,38 +376,37 @@ gimp_paint_core_stroke_emulate_dynamics (GimpCoords *coords, ...@@ -376,38 +376,37 @@ gimp_paint_core_stroke_emulate_dynamics (GimpCoords *coords,
} }
} }
if (length > 0) if (length > 1)
{ {
gint i; gint i;
gdouble delta_x;
gdouble delta_y;
/* Fill in direction */ /* Fill in direction */
for (i = 2; i < length; i++) for (i = 1; i < length; i++)
{ {
gdouble delta_x = coords[i - 1].x - coords[i].x; delta_x = coords[i - 1].x - coords[i].x;
gdouble delta_y = coords[i - 1].y - coords[i].y; delta_y = coords[i - 1].y - coords[i].y;
if (delta_x == 0) if ((delta_x == 0) && (delta_y == 0))
{ {
coords[i].direction = coords[i - 1].direction; coords[i].direction = coords[i - 1].direction;
} }
else else
{ {
coords[i].direction = 1.0 - atan (delta_y / delta_x) / (2 * G_PI); coords[i].direction = atan (delta_y / delta_x) / (2 * G_PI);
if (delta_x > 0.0)
coords[i].direction = coords[i].direction + 0.5; if (coords[i].direction < 0)
coords[i].direction += 1.0;
coords[i].direction = 1.0 - coords[i].direction;
} }
/* This should avoid confusing the interpolator on sharp
* turns where the angle warps
*/
if (fabs (coords[i].direction - coords[i - 1].direction) > 0.5)
coords[i].direction = coords[i].direction + 1.0;
} }
if (length > 2) if (length > 1)
{ {
coords[0].direction = coords[2].direction; coords[0].direction = coords[1].direction;
coords[1].direction = coords[2].direction;
} }
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment