mirror of https://github.com/GNOME/gimp.git
app: use gimp_symmetry_get_matrix() in GimpInk
... instead of calculating the matrix manually.
This commit is contained in:
parent
cd7bcd081b
commit
117734f45f
|
@ -51,46 +51,45 @@
|
||||||
|
|
||||||
/* local function prototypes */
|
/* local function prototypes */
|
||||||
|
|
||||||
static void gimp_ink_finalize (GObject *object);
|
static void gimp_ink_finalize (GObject *object);
|
||||||
|
|
||||||
static void gimp_ink_paint (GimpPaintCore *paint_core,
|
static void gimp_ink_paint (GimpPaintCore *paint_core,
|
||||||
GimpDrawable *drawable,
|
GimpDrawable *drawable,
|
||||||
GimpPaintOptions *paint_options,
|
GimpPaintOptions *paint_options,
|
||||||
GimpSymmetry *sym,
|
GimpSymmetry *sym,
|
||||||
GimpPaintState paint_state,
|
GimpPaintState paint_state,
|
||||||
guint32 time);
|
guint32 time);
|
||||||
static GeglBuffer * gimp_ink_get_paint_buffer (GimpPaintCore *paint_core,
|
static GeglBuffer * gimp_ink_get_paint_buffer (GimpPaintCore *paint_core,
|
||||||
GimpDrawable *drawable,
|
GimpDrawable *drawable,
|
||||||
GimpPaintOptions *paint_options,
|
GimpPaintOptions *paint_options,
|
||||||
GimpLayerMode paint_mode,
|
GimpLayerMode paint_mode,
|
||||||
const GimpCoords *coords,
|
const GimpCoords *coords,
|
||||||
gint *paint_buffer_x,
|
gint *paint_buffer_x,
|
||||||
gint *paint_buffer_y,
|
gint *paint_buffer_y,
|
||||||
gint *paint_width,
|
gint *paint_width,
|
||||||
gint *paint_height);
|
gint *paint_height);
|
||||||
static GimpUndo * gimp_ink_push_undo (GimpPaintCore *core,
|
static GimpUndo * gimp_ink_push_undo (GimpPaintCore *core,
|
||||||
GimpImage *image,
|
GimpImage *image,
|
||||||
const gchar *undo_desc);
|
const gchar *undo_desc);
|
||||||
|
|
||||||
static void gimp_ink_motion (GimpPaintCore *paint_core,
|
static void gimp_ink_motion (GimpPaintCore *paint_core,
|
||||||
GimpDrawable *drawable,
|
GimpDrawable *drawable,
|
||||||
GimpPaintOptions *paint_options,
|
GimpPaintOptions *paint_options,
|
||||||
GimpSymmetry *sym,
|
GimpSymmetry *sym,
|
||||||
guint32 time);
|
guint32 time);
|
||||||
|
|
||||||
static GimpBlob * ink_pen_ellipse (GimpInkOptions *options,
|
static GimpBlob * ink_pen_ellipse (GimpInkOptions *options,
|
||||||
gdouble x_center,
|
gdouble x_center,
|
||||||
gdouble y_center,
|
gdouble y_center,
|
||||||
gdouble pressure,
|
gdouble pressure,
|
||||||
gdouble xtilt,
|
gdouble xtilt,
|
||||||
gdouble ytilt,
|
gdouble ytilt,
|
||||||
gdouble velocity,
|
gdouble velocity,
|
||||||
gdouble angle,
|
const GimpMatrix3 *transform);
|
||||||
gboolean reflect);
|
|
||||||
|
|
||||||
static void render_blob (GeglBuffer *buffer,
|
static void render_blob (GeglBuffer *buffer,
|
||||||
GeglRectangle *rect,
|
GeglRectangle *rect,
|
||||||
GimpBlob *blob);
|
GimpBlob *blob);
|
||||||
|
|
||||||
|
|
||||||
G_DEFINE_TYPE (GimpInk, gimp_ink, GIMP_TYPE_PAINT_CORE)
|
G_DEFINE_TYPE (GimpInk, gimp_ink, GIMP_TYPE_PAINT_CORE)
|
||||||
|
@ -345,12 +344,11 @@ gimp_ink_motion (GimpPaintCore *paint_core,
|
||||||
|
|
||||||
for (i = 0; i < n_strokes; i++)
|
for (i = 0; i < n_strokes; i++)
|
||||||
{
|
{
|
||||||
gdouble angle;
|
GimpMatrix3 transform;
|
||||||
gboolean reflect;
|
|
||||||
|
|
||||||
coords = gimp_symmetry_get_coords (sym, i);
|
coords = gimp_symmetry_get_coords (sym, i);
|
||||||
|
|
||||||
gimp_symmetry_get_transform (sym, i, &angle, &reflect);
|
gimp_symmetry_get_matrix (sym, i, &transform);
|
||||||
|
|
||||||
last_blob = ink_pen_ellipse (options,
|
last_blob = ink_pen_ellipse (options,
|
||||||
coords->x,
|
coords->x,
|
||||||
|
@ -359,8 +357,7 @@ gimp_ink_motion (GimpPaintCore *paint_core,
|
||||||
coords->xtilt,
|
coords->xtilt,
|
||||||
coords->ytilt,
|
coords->ytilt,
|
||||||
100,
|
100,
|
||||||
angle,
|
&transform);
|
||||||
reflect);
|
|
||||||
|
|
||||||
ink->last_blobs = g_list_prepend (ink->last_blobs,
|
ink->last_blobs = g_list_prepend (ink->last_blobs,
|
||||||
last_blob);
|
last_blob);
|
||||||
|
@ -376,14 +373,13 @@ gimp_ink_motion (GimpPaintCore *paint_core,
|
||||||
{
|
{
|
||||||
for (i = 0; i < n_strokes; i++)
|
for (i = 0; i < n_strokes; i++)
|
||||||
{
|
{
|
||||||
GimpBlob *blob;
|
GimpBlob *blob;
|
||||||
GimpBlob *blob_union = NULL;
|
GimpBlob *blob_union = NULL;
|
||||||
gdouble angle;
|
GimpMatrix3 transform;
|
||||||
gboolean reflect;
|
|
||||||
|
|
||||||
coords = gimp_symmetry_get_coords (sym, i);
|
coords = gimp_symmetry_get_coords (sym, i);
|
||||||
|
|
||||||
gimp_symmetry_get_transform (sym, i, &angle, &reflect);
|
gimp_symmetry_get_matrix (sym, i, &transform);
|
||||||
|
|
||||||
blob = ink_pen_ellipse (options,
|
blob = ink_pen_ellipse (options,
|
||||||
coords->x,
|
coords->x,
|
||||||
|
@ -392,8 +388,7 @@ gimp_ink_motion (GimpPaintCore *paint_core,
|
||||||
coords->xtilt,
|
coords->xtilt,
|
||||||
coords->ytilt,
|
coords->ytilt,
|
||||||
coords->velocity * 100,
|
coords->velocity * 100,
|
||||||
angle,
|
&transform);
|
||||||
reflect);
|
|
||||||
|
|
||||||
last_blob = g_list_nth_data (ink->last_blobs, i);
|
last_blob = g_list_nth_data (ink->last_blobs, i);
|
||||||
blob_union = gimp_blob_convex_union (last_blob, blob);
|
blob_union = gimp_blob_convex_union (last_blob, blob);
|
||||||
|
@ -462,18 +457,16 @@ gimp_ink_motion (GimpPaintCore *paint_core,
|
||||||
}
|
}
|
||||||
|
|
||||||
static GimpBlob *
|
static GimpBlob *
|
||||||
ink_pen_ellipse (GimpInkOptions *options,
|
ink_pen_ellipse (GimpInkOptions *options,
|
||||||
gdouble x_center,
|
gdouble x_center,
|
||||||
gdouble y_center,
|
gdouble y_center,
|
||||||
gdouble pressure,
|
gdouble pressure,
|
||||||
gdouble xtilt,
|
gdouble xtilt,
|
||||||
gdouble ytilt,
|
gdouble ytilt,
|
||||||
gdouble velocity,
|
gdouble velocity,
|
||||||
gdouble angle,
|
const GimpMatrix3 *transform)
|
||||||
gboolean reflect)
|
|
||||||
{
|
{
|
||||||
GimpBlobFunc blob_function;
|
GimpBlobFunc blob_function;
|
||||||
GimpMatrix3 transform;
|
|
||||||
gdouble size;
|
gdouble size;
|
||||||
gdouble tsin, tcos;
|
gdouble tsin, tcos;
|
||||||
gdouble aspect, radmin;
|
gdouble aspect, radmin;
|
||||||
|
@ -551,12 +544,7 @@ ink_pen_ellipse (GimpInkOptions *options,
|
||||||
tsin = sin (options->blob_angle);
|
tsin = sin (options->blob_angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
gimp_matrix3_identity (&transform);
|
gimp_matrix3_transform_point (transform,
|
||||||
gimp_matrix3_rotate (&transform, -gimp_deg_to_rad (angle));
|
|
||||||
if (reflect)
|
|
||||||
gimp_matrix3_scale (&transform, -1.0, 1.0);
|
|
||||||
|
|
||||||
gimp_matrix3_transform_point (&transform,
|
|
||||||
tcos, tsin,
|
tcos, tsin,
|
||||||
&tcos, &tsin);
|
&tcos, &tsin);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue