[gimp] app: convert aspect ratio to scale_x&scale_y just before matrix transform
- From: Alexia Death <alexiade src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: convert aspect ratio to scale_x&scale_y just before matrix transform
- Date: Sun, 9 May 2010 21:24:32 +0000 (UTC)
commit 0cb1ada8183583c5742f0616c77cfad9becf1880
Author: Alexia Death <alexiadeath gmail com>
Date: Mon May 10 00:11:07 2010 +0300
app: convert aspect ratio to scale_x&scale_y just before matrix transform
app/core/gimpbrush-transform.c | 48 ++++++++++++++++++++-------------------
app/core/gimpbrush-transform.h | 4 +-
app/paint/gimpbrushcore.c | 3 +-
3 files changed, 29 insertions(+), 26 deletions(-)
---
diff --git a/app/core/gimpbrush-transform.c b/app/core/gimpbrush-transform.c
index 16a1726..ca83acf 100644
--- a/app/core/gimpbrush-transform.c
+++ b/app/core/gimpbrush-transform.c
@@ -63,12 +63,8 @@ gimp_brush_real_transform_size (GimpBrush *brush,
GimpMatrix3 matrix;
gint x, y;
- if (aspect_ratio < 1.0)
- gimp_brush_transform_matrix (brush->mask->width, brush->mask->height,
- scale * aspect_ratio, scale, angle, &matrix);
- else
- gimp_brush_transform_matrix (brush->mask->width, brush->mask->height,
- scale, scale / aspect_ratio, angle, &matrix);
+ gimp_brush_transform_matrix (brush->mask->width, brush->mask->height,
+ scale, aspect_ratio, angle, &matrix);
gimp_brush_transform_bounding_box (brush->mask, &matrix, &x, &y, width, height);
}
@@ -173,12 +169,8 @@ gimp_brush_real_transform_mask (GimpBrush *brush,
source = temp_buf_copy (brush->mask, NULL);
- if (aspect_ratio < 1.0)
- gimp_brush_transform_matrix (source->height, source->width,
- scale * aspect_ratio, scale, angle, &matrix);
- else
- gimp_brush_transform_matrix (source->height, source->width,
- scale, scale / aspect_ratio, angle, &matrix);
+ gimp_brush_transform_matrix (source->height, source->width,
+ scale, aspect_ratio, angle, &matrix);
if (gimp_matrix3_is_identity (&matrix))
return temp_buf_copy (source, NULL);
@@ -460,12 +452,8 @@ gimp_brush_real_transform_pixmap (GimpBrush *brush,
source = brush->pixmap;
- if (aspect_ratio < 1.0)
- gimp_brush_transform_matrix (source->height, source->width,
- scale * aspect_ratio, scale, angle, &matrix);
- else
- gimp_brush_transform_matrix (source->height, source->width,
- scale, scale / aspect_ratio, angle, &matrix);
+ gimp_brush_transform_matrix (source->height, source->width,
+ scale, aspect_ratio, angle, &matrix);
if (gimp_matrix3_is_identity (&matrix))
return temp_buf_copy (source, NULL);
@@ -653,19 +641,33 @@ gimp_brush_real_transform_pixmap (GimpBrush *brush,
void
gimp_brush_transform_matrix (gdouble width,
gdouble height,
- gdouble scale_x,
- gdouble scale_y,
+ gdouble scale,
+ gdouble aspect_ratio,
gdouble angle,
GimpMatrix3 *matrix)
{
const gdouble center_x = width / 2;
const gdouble center_y = height / 2;
+ gdouble scale_x;
+ gdouble scale_y;
+
+ if (aspect_ratio < 1.0)
+ {
+ scale_x = scale * aspect_ratio;
+ scale_y = scale;
+ }
+ else
+ {
+ scale_x = scale;
+ scale_y = scale / aspect_ratio;
+ }
gimp_matrix3_identity (matrix);
- gimp_matrix3_translate (matrix, - center_x, - center_y);
- gimp_matrix3_rotate (matrix, -2 * G_PI * angle);
- gimp_matrix3_translate (matrix, center_x, center_y);
gimp_matrix3_scale (matrix, scale_x, scale_y);
+ gimp_matrix3_translate (matrix, - center_x * scale_x, - center_y * scale_y);
+ gimp_matrix3_rotate (matrix, -2 * G_PI * angle);
+ gimp_matrix3_translate (matrix, center_x * scale_x, center_y * scale_y);
+
}
/* private functions */
diff --git a/app/core/gimpbrush-transform.h b/app/core/gimpbrush-transform.h
index 7b3af61..5a587c2 100644
--- a/app/core/gimpbrush-transform.h
+++ b/app/core/gimpbrush-transform.h
@@ -42,8 +42,8 @@ TempBuf * gimp_brush_real_transform_pixmap (GimpBrush *brush,
void gimp_brush_transform_matrix (gdouble width,
gdouble height,
- gdouble scale_x,
- gdouble scale_y,
+ gdouble scale,
+ gdouble aspect_ratio,
gdouble angle,
GimpMatrix3 *matrix);
diff --git a/app/paint/gimpbrushcore.c b/app/paint/gimpbrushcore.c
index 8cbb871..25273ad 100644
--- a/app/paint/gimpbrushcore.c
+++ b/app/paint/gimpbrushcore.c
@@ -1049,13 +1049,14 @@ gimp_brush_core_transform_bound_segs (GimpBrushCore *core,
gimp_brush_transform_matrix (height, width,
- scale_x, scale_y, angle, &matrix);
+ scale, aspect_ratio, angle, &matrix);
core->transformed_brush_bound_segs
= boundary_transform (core->brush_bound_segs,
&core->n_brush_bound_segs,
&matrix);
+ //FIXME. Do noy use scale_x/scale_y
core->transformed_brush_bound_width = core->brush_bound_width * scale_x;
core->transformed_brush_bound_height = core->brush_bound_height * scale_y;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]