Commit eef4ea03 authored by David Odin's avatar David Odin
Browse files

fixed some compiler warnings and did some cleanups.

* plug-ins/ifscompose/ifscompose_utils.c: fixed some compiler warnings
  and did some cleanups.
parent d8288f92
2005-12-30 DindinX <dindinx@gimp.org>
* plug-ins/ifscompose/ifscompose_utils.c: fixed some compiler warnings
and did some cleanups.
2005-12-30 DindinX <dindinx@gimp.org>
* plug-ins/gfig/gfig-arc.c
......
......@@ -40,18 +40,18 @@ typedef struct
/* local functions */
static void aff_element_compute_click_boundary (AffElement *elem,
gint num_elements,
gdouble *points_x,
gdouble *points_y);
gint num_elements,
gdouble *points_x,
gdouble *points_y);
static guchar * create_brush (IfsComposeVals *ifsvals,
gint *brush_size,
gdouble *brush_offset);
gint *brush_size,
gdouble *brush_offset);
void
aff2_translate (Aff2 *naff,
gdouble x,
gdouble y)
gdouble x,
gdouble y)
{
naff->a11 = 1.0;
naff->a12 = 0;
......@@ -63,7 +63,7 @@ aff2_translate (Aff2 *naff,
void
aff2_rotate (Aff2 *naff,
gdouble theta)
gdouble theta)
{
naff->a11 = cos(theta);
naff->a12 = sin(theta);
......@@ -74,9 +74,9 @@ aff2_rotate (Aff2 *naff,
}
void
aff2_scale(Aff2 *naff,
gdouble s,
gint flip)
aff2_scale (Aff2 *naff,
gdouble s,
gboolean flip)
{
if (flip)
naff->a11 = -s;
......@@ -93,8 +93,8 @@ aff2_scale(Aff2 *naff,
/* Create a unitary transform with given x-y asymmetry and shear */
void
aff2_distort (Aff2 *naff,
gdouble asym,
gdouble shear)
gdouble asym,
gdouble shear)
{
naff->a11 = asym;
naff->a22 = 1/asym;
......@@ -107,14 +107,14 @@ aff2_distort (Aff2 *naff,
/* Find a pure stretch in some directon that brings xo,yo to xn,yn */
void
aff2_compute_stretch (Aff2 *naff,
gdouble xo,
gdouble yo,
gdouble xn,
gdouble yn)
gdouble xo,
gdouble yo,
gdouble xn,
gdouble yn)
{
gdouble denom = xo*xn + yo*yn;
if (denom == 0.0) /* singular */
if (denom == 0.0) /* singular */
{
naff->a11 = 1.0;
naff->a12 = 0.0;
......@@ -134,8 +134,8 @@ aff2_compute_stretch (Aff2 *naff,
void
aff2_compose (Aff2 *naff,
Aff2 *aff1,
Aff2 *aff2)
Aff2 *aff1,
Aff2 *aff2)
{
naff->a11 = aff1->a11 * aff2->a11 + aff1->a12 * aff2->a21;
naff->a12 = aff1->a11 * aff2->a12 + aff1->a12 * aff2->a22;
......@@ -148,7 +148,7 @@ aff2_compose (Aff2 *naff,
/* Returns the identity matrix if the original matrix was singular */
void
aff2_invert (Aff2 *naff,
Aff2 *aff)
Aff2 *aff)
{
gdouble det = aff->a11 * aff->a22 - aff->a12 * aff->a21;
......@@ -169,10 +169,10 @@ aff2_invert (Aff2 *naff,
void
aff2_apply (Aff2 *aff,
gdouble x,
gdouble y,
gdouble *xf,
gdouble *yf)
gdouble x,
gdouble y,
gdouble *xf,
gdouble *yf)
{
gdouble xt = aff->a11 * x + aff->a12 * y + aff->b1;
gdouble yt = aff->a21 * x + aff->a22 * y + aff->b2;
......@@ -186,8 +186,8 @@ aff2_apply (Aff2 *aff,
void
aff2_fixed_point (Aff2 *aff,
gdouble *xf,
gdouble *yf)
gdouble *xf,
gdouble *yf)
{
Aff2 t1,t2;
......@@ -204,12 +204,12 @@ aff2_fixed_point (Aff2 *aff,
void
aff3_apply (Aff3 *t,
gdouble x,
gdouble y,
gdouble z,
gdouble *xf,
gdouble *yf,
gdouble *zf)
gdouble x,
gdouble y,
gdouble z,
gdouble *xf,
gdouble *yf,
gdouble *zf)
{
gdouble xt = (t->vals[0][0] * x +
t->vals[0][1] * y +
......@@ -228,7 +228,7 @@ aff3_apply (Aff3 *t,
static int
ipolygon_sort_func (const void *a,
const void *b)
const void *b)
{
if (((SortPoint *)a)->angle < ((SortPoint *)b)->angle)
return -1;
......@@ -272,36 +272,36 @@ ipolygon_convex_hull (IPolygon *poly)
lowest_pt = poly->points[0];
lowest = 0;
for (i=1;i<num_new;i++)
for (i = 1; i < num_new; i++)
if (poly->points[i].y < lowest_pt.y)
{
lowest_pt = poly->points[i];
lowest = i;
lowest_pt = poly->points[i];
lowest = i;
}
/* sort by angle from lowest point */
for (i=0,j=0;i<num_new;i++,j++)
for (i = 0, j = 0; i < num_new; i++, j++)
{
if (i==lowest)
j--;
j--;
else
{
gdouble dy = poly->points[i].y - lowest_pt.y;
gdouble dx = poly->points[i].x - lowest_pt.x;
if (dy==0 && dx==0)
{
j--;
num_new--;
continue;
}
sort_points[j].point = poly->points[i];
sort_points[j].angle = atan2 (dy, dx);
}
{
gdouble dy = poly->points[i].y - lowest_pt.y;
gdouble dx = poly->points[i].x - lowest_pt.x;
if (dy == 0 && dx == 0)
{
j--;
num_new--;
continue;
}
sort_points[j].point = poly->points[i];
sort_points[j].angle = atan2 (dy, dx);
}
}
qsort (sort_points, num_new-1, sizeof (SortPoint), ipolygon_sort_func);
qsort (sort_points, num_new - 1, sizeof (SortPoint), ipolygon_sort_func);
/* now ensure that all turns as we trace the perimiter are
counter-clockwise */
......@@ -311,27 +311,27 @@ ipolygon_convex_hull (IPolygon *poly)
x1 = new_points[1].x - new_points[0].x;
y1 = new_points[1].y - new_points[0].y;
for (i=1,j=2;j<num_new;i++,j++)
for (i = 1, j = 2; j < num_new; i++, j++)
{
x2 = sort_points[i].point.x - new_points[j-1].x;
y2 = sort_points[i].point.y - new_points[j-1].y;
if (x2==0 && y2==0)
{
num_new--;
j--;
continue;
}
while (x1*y2 - x2*y1 < 0) /* clockwise rotation */
{
num_new--;
j--;
x1 = new_points[j-1].x - new_points[j-2].x;
y1 = new_points[j-1].y - new_points[j-2].y;
x2 = sort_points[i].point.x - new_points[j-1].x;
y2 = sort_points[i].point.y - new_points[j-1].y;
}
x2 = sort_points[i].point.x - new_points[j - 1].x;
y2 = sort_points[i].point.y - new_points[j - 1].y;
if (x2 == 0 && y2 == 0)
{
num_new--;
j--;
continue;
}
while (x1 * y2 - x2 * y1 < 0) /* clockwise rotation */
{
num_new--;
j--;
x1 = new_points[j - 1].x - new_points[j - 2].x;
y1 = new_points[j - 1].y - new_points[j - 2].y;
x2 = sort_points[i].point.x - new_points[j - 1].x;
y2 = sort_points[i].point.y - new_points[j - 1].y;
}
new_points[j] = sort_points[i].point;
x1 = x2;
y1 = y2;
......@@ -354,8 +354,8 @@ ipolygon_convex_hull (IPolygon *poly)
gint
ipolygon_contains (IPolygon *poly,
gint xt,
gint yt)
gint xt,
gint yt)
{
gint xnew, ynew;
gint xold, yold;
......@@ -368,29 +368,29 @@ ipolygon_contains (IPolygon *poly,
if (poly->npoints < 3)
return 0;
xold=poly->points[poly->npoints-1].x;
yold=poly->points[poly->npoints-1].y;
for (i=0;i<poly->npoints;i++)
xold=poly->points[poly->npoints - 1].x;
yold=poly->points[poly->npoints - 1].y;
for (i = 0; i < poly->npoints; i++)
{
xnew = poly->points[i].x;
ynew = poly->points[i].y;
if (xnew > xold)
{
x1 = xold;
x2 = xnew;
y1 = yold;
y2 = ynew;
}
{
x1 = xold;
x2 = xnew;
y1 = yold;
y2 = ynew;
}
else
{
x1 = xnew;
x2 = xold;
y1 = ynew;
y2 = yold;
}
{
x1 = xnew;
x2 = xold;
y1 = ynew;
y2 = yold;
}
if ((xnew < xt) == (xt <= xold) &&
(yt - y1)*(x2 - x1) < (y2 - y1)*(xt - x1))
inside = !inside;
(yt - y1)*(x2 - x1) < (y2 - y1)*(xt - x1))
inside = !inside;
xold = xnew;
yold = ynew;
}
......@@ -400,104 +400,103 @@ ipolygon_contains (IPolygon *poly,
void
aff_element_compute_color_trans (AffElement *elem)
{
int i,j;
int i, j;
if (elem->v.simple_color)
{
gdouble mag2;
mag2 = SQR(elem->v.target_color.r);
mag2 += SQR(elem->v.target_color.g);
mag2 += SQR(elem->v.target_color.b);
mag2 = SQR (elem->v.target_color.r);
mag2 += SQR (elem->v.target_color.g);
mag2 += SQR (elem->v.target_color.b);
/* For mag2 == 0, the transformation blows up in general
but is well defined for hue_scale == value_scale, so
we assume that special case. */
but is well defined for hue_scale == value_scale, so
we assume that special case. */
if (mag2 == 0)
for (i=0; i<3; i++)
{
for (j=0; j<4; j++)
elem->color_trans.vals[i][j] = 0.0;
for (i = 0; i < 3; i++)
{
for (j = 0; j < 4; j++)
elem->color_trans.vals[i][j] = 0.0;
elem->color_trans.vals[i][i] = elem->v.hue_scale;
}
elem->color_trans.vals[i][i] = elem->v.hue_scale;
}
else
{
/* red */
for (j=0; j<3; j++)
{
elem->color_trans.vals[0][j] = elem->v.target_color.r
/ mag2 * (elem->v.value_scale - elem->v.hue_scale);
}
/* green */
for (j=0; j<3; j++)
{
elem->color_trans.vals[1][j] = elem->v.target_color.g
/ mag2 * (elem->v.value_scale - elem->v.hue_scale);
}
/* blue */
for (j=0; j<3; j++)
{
elem->color_trans.vals[2][j] = elem->v.target_color.g
/ mag2 * (elem->v.value_scale - elem->v.hue_scale);
}
elem->color_trans.vals[0][0] += elem->v.hue_scale;
elem->color_trans.vals[1][1] += elem->v.hue_scale;
elem->color_trans.vals[2][2] += elem->v.hue_scale;
elem->color_trans.vals[0][3] =
(1-elem->v.value_scale)*elem->v.target_color.r;
elem->color_trans.vals[1][3] =
(1-elem->v.value_scale)*elem->v.target_color.g;
elem->color_trans.vals[2][3] =
(1-elem->v.value_scale)*elem->v.target_color.b;
}
{
/* red */
for (j = 0; j < 3; j++)
{
elem->color_trans.vals[0][j] = elem->v.target_color.r
/ mag2 * (elem->v.value_scale - elem->v.hue_scale);
}
/* green */
for (j = 0; j < 3; j++)
{
elem->color_trans.vals[1][j] = elem->v.target_color.g
/ mag2 * (elem->v.value_scale - elem->v.hue_scale);
}
/* blue */
for (j = 0; j < 3; j++)
{
elem->color_trans.vals[2][j] = elem->v.target_color.g
/ mag2 * (elem->v.value_scale - elem->v.hue_scale);
}
elem->color_trans.vals[0][0] += elem->v.hue_scale;
elem->color_trans.vals[1][1] += elem->v.hue_scale;
elem->color_trans.vals[2][2] += elem->v.hue_scale;
elem->color_trans.vals[0][3] =
(1 - elem->v.value_scale) * elem->v.target_color.r;
elem->color_trans.vals[1][3] =
(1 - elem->v.value_scale) * elem->v.target_color.g;
elem->color_trans.vals[2][3] =
(1 - elem->v.value_scale) * elem->v.target_color.b;
}
aff3_apply (&elem->color_trans, 1.0, 0.0, 0.0,
&elem->v.red_color.r,
&elem->v.red_color.g,
&elem->v.red_color.b);
&elem->v.red_color.r,
&elem->v.red_color.g,
&elem->v.red_color.b);
aff3_apply (&elem->color_trans, 0.0, 1.0, 0.0,
&elem->v.green_color.r,
&elem->v.green_color.g,
&elem->v.green_color.b);
&elem->v.green_color.r,
&elem->v.green_color.g,
&elem->v.green_color.b);
aff3_apply (&elem->color_trans, 0.0, 0.0, 1.0,
&elem->v.blue_color.r,
&elem->v.blue_color.g,
&elem->v.blue_color.b);
&elem->v.blue_color.r,
&elem->v.blue_color.g,
&elem->v.blue_color.b);
aff3_apply (&elem->color_trans, 0.0, 0.0, 0.0,
&elem->v.black_color.r,
&elem->v.black_color.g,
&elem->v.black_color.b);
&elem->v.black_color.r,
&elem->v.black_color.g,
&elem->v.black_color.b);
}
else
{
elem->color_trans.vals[0][0] =
elem->v.red_color.r - elem->v.black_color.r;
elem->v.red_color.r - elem->v.black_color.r;
elem->color_trans.vals[1][0] =
elem->v.red_color.g - elem->v.black_color.g;
elem->v.red_color.g - elem->v.black_color.g;
elem->color_trans.vals[2][0] =
elem->v.red_color.b - elem->v.black_color.b;
elem->v.red_color.b - elem->v.black_color.b;
elem->color_trans.vals[0][1] =
elem->v.green_color.r - elem->v.black_color.r;
elem->v.green_color.r - elem->v.black_color.r;
elem->color_trans.vals[1][1] =
elem->v.green_color.g - elem->v.black_color.g;
elem->v.green_color.g - elem->v.black_color.g;
elem->color_trans.vals[2][1] =
elem->v.green_color.b - elem->v.black_color.b;
elem->v.green_color.b - elem->v.black_color.b;
elem->color_trans.vals[0][2] =
elem->v.blue_color.r - elem->v.black_color.r;
elem->v.blue_color.r - elem->v.black_color.r;
elem->color_trans.vals[1][2] =
elem->v.blue_color.g - elem->v.black_color.g;
elem->v.blue_color.g - elem->v.black_color.g;
elem->color_trans.vals[2][2] =
elem->v.blue_color.b - elem->v.black_color.b;
elem->v.blue_color.b - elem->v.black_color.b;
elem->color_trans.vals[0][3] = elem->v.black_color.r;
elem->color_trans.vals[1][3] = elem->v.black_color.g;
......@@ -507,10 +506,10 @@ aff_element_compute_color_trans (AffElement *elem)
void
aff_element_compute_trans (AffElement *elem,
gdouble width,
gdouble height,
gdouble center_x,
gdouble center_y)
gdouble width,
gdouble height,
gdouble center_x,
gdouble center_y)
{
Aff2 t1, t2, t3;
......@@ -530,18 +529,18 @@ aff_element_compute_trans (AffElement *elem,
void
aff_element_decompose_trans (AffElement *elem,
Aff2 *aff,
gdouble width,
gdouble height,
gdouble center_x,
gdouble center_y)
Aff2 *aff,
gdouble width,
gdouble height,
gdouble center_x,
gdouble center_y)
{
Aff2 t1,t2;
gdouble det,scale,sign;
Aff2 t1, t2;
gdouble det, scale, sign;
/* pull of the translational parts */
aff2_translate (&t1,center_x*width,center_y*width);
aff2_compose (&t2,aff,&t1);
aff2_translate (&t1,center_x * width, center_y * width);
aff2_compose (&t2, aff, &t1);
elem->v.x = t2.b1 / width;
elem->v.y = t2.b2 / width;
......@@ -559,58 +558,58 @@ aff_element_decompose_trans (AffElement *elem,
else
{
if (det >= 0)
{
scale = elem->v.scale = sqrt (det);
sign = 1;
elem->v.flip = 0;
}
{
scale = elem->v.scale = sqrt (det);
sign = 1;
elem->v.flip = 0;
}
else
{
scale = elem->v.scale = sqrt (-det);
sign = -1;
elem->v.flip = 1;
}
{
scale = elem->v.scale = sqrt (-det);
sign = -1;
elem->v.flip = 1;
}
elem->v.theta = atan2 (-t2.a21, t2.a11);
if (cos (elem->v.theta) == 0.0)
{
elem->v.asym = - t2.a21 / scale / sin(elem->v.theta);
elem->v.shear = - sign * t2.a22 / scale / sin(elem->v.theta);
}
{
elem->v.asym = - t2.a21 / scale / sin (elem->v.theta);
elem->v.shear = - sign * t2.a22 / scale / sin (elem->v.theta);
}
else
{
elem->v.asym = sign * t2.a11 / scale / cos(elem->v.theta);
elem->v.shear = sign *
(t2.a12/scale - sin(elem->v.theta)/elem->v.asym)
/ cos(elem->v.theta);
}
{
elem->v.asym = sign * t2.a11 / scale / cos (elem->v.theta);
elem->v.shear = sign *
(t2.a12/scale - sin (elem->v.theta)/elem->v.asym)
/ cos (elem->v.theta);
}
}
}
static void
aff_element_compute_click_boundary (AffElement *elem,
int num_elements,
gdouble *points_x,