Commit 6ed9b2bb authored by Ell's avatar Ell

Issue #4846 - Symmetry origin is wrong when painting on offset drawable

In gimp_symmetry_{mirror,mandala}_update_strokes(), adjust the
symmetry origin according to the drawable offset, so that it
remains fixed relative to the image regardless of the drawable
position.
parent 75435c8e
Pipeline #163871 passed with stages
in 39 minutes and 14 seconds
......@@ -457,9 +457,16 @@ gimp_mandala_update_strokes (GimpSymmetry *sym,
GimpMandala *mandala = GIMP_MANDALA (sym);
GimpCoords *coords;
GimpMatrix3 matrix;
gdouble slice_angle;
gdouble mid_slice_angle = 0.0;
gdouble center_x, center_y;
gint offset_x, offset_y;
gint i;
gdouble slice_angle;
gdouble mid_slice_angle = 0.0;
gimp_item_get_offset (GIMP_ITEM (drawable), &offset_x, &offset_y);
center_x = mandala->center_x - offset_x;
center_y = mandala->center_y - offset_y;
g_list_free_full (sym->strokes, g_free);
sym->strokes = NULL;
......@@ -473,8 +480,8 @@ gimp_mandala_update_strokes (GimpSymmetry *sym,
if (mandala->enable_reflection)
{
/* Find out in which slice the user is currently drawing. */
gdouble angle = atan2 (sym->origin->y - mandala->center_y,
sym->origin->x - mandala->center_x);
gdouble angle = atan2 (sym->origin->y - center_y,
sym->origin->x - center_x);
gint slice_no = (int) floor(angle/slice_angle);
/* Angle where the middle of that slice is. */
......@@ -488,8 +495,8 @@ gimp_mandala_update_strokes (GimpSymmetry *sym,
coords = g_memdup (sym->origin, sizeof (GimpCoords));
gimp_matrix3_identity (&matrix);
gimp_matrix3_translate (&matrix,
- mandala->center_x,
- mandala->center_y);
-center_x,
-center_y);
if (mandala->enable_reflection && i % 2 == 1)
{
/* Reflecting over the mid_slice_angle axis, reflects slice without changing position. */
......@@ -502,8 +509,8 @@ gimp_mandala_update_strokes (GimpSymmetry *sym,
gimp_matrix3_rotate (&matrix, - i * slice_angle);
}
gimp_matrix3_translate (&matrix,
mandala->center_x,
mandala->center_y);
+center_x,
+center_y);
gimp_matrix3_transform_point (&matrix,
coords->x,
coords->y,
......
......@@ -326,6 +326,13 @@ gimp_mirror_update_strokes (GimpSymmetry *sym,
GimpMirror *mirror = GIMP_MIRROR (sym);
GList *strokes = NULL;
GimpCoords *coords;
gdouble mirror_position_x, mirror_position_y;
gint offset_x, offset_y;
gimp_item_get_offset (GIMP_ITEM (drawable), &offset_x, &offset_y);
mirror_position_x = mirror->mirror_position_x - offset_x;
mirror_position_y = mirror->mirror_position_y - offset_y;
g_list_free_full (sym->strokes, g_free);
strokes = g_list_prepend (strokes,
......@@ -334,22 +341,22 @@ gimp_mirror_update_strokes (GimpSymmetry *sym,
if (mirror->horizontal_mirror)
{
coords = g_memdup (origin, sizeof (GimpCoords));
coords->y = 2.0 * mirror->mirror_position_y - origin->y;
coords->y = 2.0 * mirror_position_y - origin->y;
strokes = g_list_prepend (strokes, coords);
}
if (mirror->vertical_mirror)
{
coords = g_memdup (origin, sizeof (GimpCoords));
coords->x = 2.0 * mirror->mirror_position_x - origin->x;
coords->x = 2.0 * mirror_position_x - origin->x;
strokes = g_list_prepend (strokes, coords);
}
if (mirror->point_symmetry)
{
coords = g_memdup (origin, sizeof (GimpCoords));
coords->x = 2.0 * mirror->mirror_position_x - origin->x;
coords->y = 2.0 * mirror->mirror_position_y - origin->y;
coords->x = 2.0 * mirror_position_x - origin->x;
coords->y = 2.0 * mirror_position_y - origin->y;
strokes = g_list_prepend (strokes, coords);
}
......
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