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.
(cherry picked from commit 6ed9b2bb7a
)
This commit is contained in:
@ -456,9 +456,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;
|
||||
@ -472,8 +479,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. */
|
||||
@ -487,8 +494,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. */
|
||||
@ -501,8 +508,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,
|
||||
|
@ -325,6 +325,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,
|
||||
@ -333,22 +340,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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user