app: A few more generic aspect ratio fixes

This commit is contained in:
Alexia Death 2010-05-14 20:57:48 +03:00
parent 45a8d2c63c
commit b0d02666a3
2 changed files with 47 additions and 20 deletions

View File

@ -300,23 +300,35 @@ gimp_brush_generated_transform_size (GimpBrush *gbrush,
GimpBrushGenerated *brush = GIMP_BRUSH_GENERATED (gbrush);
gint half_width;
gint half_height;
gdouble ratio;
/* Since generated brushes are symmetric the dont have intput
* for aspect ratios < 1.0. its same as rotate by 90 degrees and
* 1 / ratio. So we fix the input up for this case. */
if (aspect_ratio < 1.0)
if (aspect_ratio == 1.0)
{
aspect_ratio = 1.0 / aspect_ratio;
angle = angle + 0.25;
ratio = brush->aspect_ratio;
}
else
{
ratio = MIN (aspect_ratio, 20);
/* Since generated brushes are symmetric the dont have input
* for aspect ratios < 1.0. its same as rotate by 90 degrees and
* 1 / ratio. So we fix the input up for this case. */
if (ratio < 1.0)
{
ratio = MIN (1.0 / ratio, 20);
angle = angle + 0.25;
}
}
gimp_brush_generated_get_half_size (brush,
brush->shape,
brush->radius * scale,
brush->spikes,
brush->hardness,
MIN (brush->aspect_ratio * aspect_ratio, 20),
ratio,
(brush->angle + 360 * angle),
&half_width, &half_height,
NULL, NULL, NULL, NULL);
@ -333,23 +345,33 @@ gimp_brush_generated_transform_mask (GimpBrush *gbrush,
gdouble hardness)
{
GimpBrushGenerated *brush = GIMP_BRUSH_GENERATED (gbrush);
gdouble ratio;
/* Since generated brushes are symmetric the dont have intput
* for aspect ratios < 1.0. its same as rotate by extra 90 degrees and
* 1 / ratio. So we fix the input up for this case. */
if (aspect_ratio < 1.0)
if (aspect_ratio == 1.0)
{
aspect_ratio = 1.0 / aspect_ratio;
angle = angle + 0.25;
ratio = brush->aspect_ratio;
}
else
{
ratio = MIN (aspect_ratio, 20);
/* Since generated brushes are symmetric the dont have input
* for aspect ratios < 1.0. its same as rotate by 90 degrees and
* 1 / ratio. So we fix the input up for this case. */
if (ratio < 1.0)
{
ratio = MIN (1.0 / ratio, 20);
angle = angle + 0.25;
}
}
return gimp_brush_generated_calc (brush,
brush->shape,
brush->radius * scale ,
brush->spikes,
brush->hardness * hardness,
brush->aspect_ratio * aspect_ratio,
ratio,
(brush->angle + 360 * angle),
NULL, NULL);
}

View File

@ -1025,13 +1025,18 @@ gimp_brush_core_transform_bound_segs (GimpBrushCore *core,
angle = core->angle;
aspect_ratio = core->aspect_ratio;
/* Generated brushes have their aspect ratio appled before base angle */
if (aspect_ratio != 1.0 && GIMP_IS_BRUSH_GENERATED (core->main_brush))
/* Generated brushes have their angle applied on top of base angle */
if (GIMP_IS_BRUSH_GENERATED (core->main_brush))
{
gdouble base_angle = gimp_brush_generated_get_angle (
GIMP_BRUSH_GENERATED (core->main_brush));
GimpBrushGenerated *generated_brush = GIMP_BRUSH_GENERATED (core->main_brush);
gdouble base_angle = gimp_brush_generated_get_angle (generated_brush);
angle = angle + base_angle / 360;
/* Dont apply the ratio. I wont make sense. The outlines for generated brushes need to be recreated */
aspect_ratio = 1.0;
}
height = core->brush_bound_width;
width = core->brush_bound_height;