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
......
......@@ -74,9 +74,9 @@ aff2_rotate (Aff2 *naff,
}
void
aff2_scale(Aff2 *naff,
aff2_scale (Aff2 *naff,
gdouble s,
gint flip)
gboolean flip)
{
if (flip)
naff->a11 = -s;
......@@ -272,7 +272,7 @@ 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];
......@@ -281,7 +281,7 @@ ipolygon_convex_hull (IPolygon *poly)
/* 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--;
......@@ -290,7 +290,7 @@ ipolygon_convex_hull (IPolygon *poly)
gdouble dy = poly->points[i].y - lowest_pt.y;
gdouble dx = poly->points[i].x - lowest_pt.x;
if (dy==0 && dx==0)
if (dy == 0 && dx == 0)
{
j--;
num_new--;
......@@ -301,7 +301,7 @@ ipolygon_convex_hull (IPolygon *poly)
}
}
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,26 +311,26 @@ 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;
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)
if (x2 == 0 && y2 == 0)
{
num_new--;
j--;
continue;
}
while (x1*y2 - x2*y1 < 0) /* clockwise rotation */
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;
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;
......@@ -368,9 +368,9 @@ 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;
......@@ -400,23 +400,23 @@ 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. */
if (mag2 == 0)
for (i=0; i<3; i++)
for (i = 0; i < 3; i++)
{
for (j=0; j<4; j++)
for (j = 0; j < 4; j++)
elem->color_trans.vals[i][j] = 0.0;
elem->color_trans.vals[i][i] = elem->v.hue_scale;
......@@ -424,21 +424,21 @@ aff_element_compute_color_trans (AffElement *elem)
else
{
/* red */
for (j=0; j<3; j++)
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++)
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++)
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);
......@@ -448,13 +448,12 @@ aff_element_compute_color_trans (AffElement *elem)
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;
(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;
(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;
(1 - elem->v.value_scale) * elem->v.target_color.b;
}
......@@ -536,12 +535,12 @@ aff_element_decompose_trans (AffElement *elem,
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;
......@@ -575,15 +574,15 @@ aff_element_decompose_trans (AffElement *elem,
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.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);
(t2.a12/scale - sin (elem->v.theta)/elem->v.asym)
/ cos (elem->v.theta);
}
}
}
......@@ -599,18 +598,18 @@ aff_element_compute_click_boundary (AffElement *elem,
gdouble ytot = 0;
gdouble xc, yc;
gdouble theta;
gdouble sth,cth; /* sin(theta), cos(theta) */
gdouble axis1,axis2;
gdouble sth, cth; /* sin(theta), cos(theta) */
gdouble axis1, axis2;
gdouble axis1max, axis2max, axis1min, axis2min;
/* compute the center of mass of the points */
for (i=0; i<num_elements; i++)
for (i = 0; i < num_elements; i++)
{
xtot += points_x[i];
ytot += points_y[i];
}
xc = xtot/num_elements;
yc = ytot/num_elements;
xc = xtot / num_elements;
yc = ytot / num_elements;
/* compute the sum of the (x+iy)^2, and take half the the resulting
angle (xtot+iytot = A*exp(2i*theta)), to get an average direction */
......@@ -622,19 +621,19 @@ aff_element_compute_click_boundary (AffElement *elem,
xtot += SQR (points_x[i] - xc) - SQR (points_y[i] - yc);
ytot += 2 * (points_x[i] - xc) * (points_y[i] - yc);
}
theta = 0.5*atan2(ytot,xtot);
sth = sin(theta);
cth = cos(theta);
theta = 0.5 * atan2 (ytot, xtot);
sth = sin (theta);
cth = cos (theta);
/* compute the minimum rectangle at angle theta that bounds the points,
1/2 side lenghs left in axis1, axis2, center in xc, yc */
axis1max = axis1min = 0.0;
axis2max = axis2min = 0.0;
for (i=0; i<num_elements; i++)
for (i = 0; i < num_elements; i++)
{
gdouble proj1 = (points_x[i]-xc)*cth + (points_y[i]-yc)*sth;
gdouble proj2 = -(points_x[i]-xc)*sth + (points_y[i]-yc)*cth;
gdouble proj1 = (points_x[i] - xc) * cth + (points_y[i] - yc) * sth;
gdouble proj2 = -(points_x[i] - xc) * sth + (points_y[i] - yc) * cth;
if (proj1 < axis1min)
axis1min = proj1;
if (proj1 > axis1max)
......@@ -644,33 +643,33 @@ aff_element_compute_click_boundary (AffElement *elem,
if (proj2 > axis2max)
axis2max = proj2;
}
axis1 = 0.5*(axis1max - axis1min);
axis2 = 0.5*(axis2max - axis2min);
xc += 0.5*((axis1max + axis1min)*cth - (axis2max+axis2min)*sth);
yc += 0.5*((axis1max + axis1min)*sth + (axis2max+axis2min)*cth);
axis1 = 0.5 * (axis1max - axis1min);
axis2 = 0.5 * (axis2max - axis2min);
xc += 0.5 * ((axis1max + axis1min) * cth - (axis2max + axis2min) * sth);
yc += 0.5 * ((axis1max + axis1min) * sth + (axis2max + axis2min) * cth);
/* if the the rectangle is less than 10 pixels in any dimension,
make it click_boundary, otherwise set click_boundary = draw_boundary */
if (axis1 < 8.0 || axis2 < 8.0)
{
GdkPoint *points = g_new (GdkPoint,4);
GdkPoint *points = g_new (GdkPoint, 4);
elem->click_boundary = g_new (IPolygon,1);
elem->click_boundary = g_new (IPolygon, 1);
elem->click_boundary->points = points;
elem->click_boundary->npoints = 4;
if (axis1 < 8.0) axis1 = 8.0;
if (axis2 < 8.0) axis2 = 8.0;
points[0].x = xc + axis1*cth - axis2*sth;
points[0].y = yc + axis1*sth + axis2*cth;
points[1].x = xc - axis1*cth - axis2*sth;
points[1].y = yc - axis1*sth + axis2*cth;
points[2].x = xc - axis1*cth + axis2*sth;
points[2].y = yc - axis1*sth - axis2*cth;
points[3].x = xc + axis1*cth + axis2*sth;
points[3].y = yc + axis1*sth - axis2*cth;
points[0].x = xc + axis1 * cth - axis2 * sth;
points[0].y = yc + axis1 * sth + axis2 * cth;
points[1].x = xc - axis1 * cth - axis2 * sth;
points[1].y = yc - axis1 * sth + axis2 * cth;
points[2].x = xc - axis1 * cth + axis2 * sth;
points[2].y = yc - axis1 * sth - axis2 * cth;
points[3].x = xc + axis1 * cth + axis2 * sth;
points[3].y = yc + axis1 * sth - axis2 * cth;
}
else
elem->click_boundary = elem->draw_boundary;
......@@ -683,7 +682,7 @@ aff_element_compute_boundary (AffElement *elem,
AffElement **elements,
gint num_elements)
{
int i;
gint i;
IPolygon tmp_poly;
gdouble *points_x;
gdouble *points_y;
......@@ -698,16 +697,17 @@ aff_element_compute_boundary (AffElement *elem,
points_x = g_new (gdouble, num_elements);
points_y = g_new (gdouble, num_elements);
for (i=0;i<num_elements;i++)
for (i = 0; i < num_elements; i++)
{
aff2_apply (&elem->trans,elements[i]->v.x*width,elements[i]->v.y*width,
aff2_apply (&elem->trans,
elements[i]->v.x * width, elements[i]->v.y * width,
&points_x[i],&points_y[i]);
tmp_poly.points[i].x = (gint)points_x[i];
tmp_poly.points[i].y = (gint)points_y[i];
}
elem->draw_boundary = ipolygon_convex_hull (&tmp_poly);
aff_element_compute_click_boundary (elem,num_elements,points_x,points_y);
aff_element_compute_click_boundary (elem, num_elements, points_x, points_y);
g_free (tmp_poly.points);
}
......@@ -752,7 +752,7 @@ aff_element_new (gdouble x,
GimpRGB *color,
gint count)
{
AffElement *elem = g_new(AffElement, 1);
AffElement *elem = g_new (AffElement, 1);
gchar buffer[16];
elem->v.x = x;
......@@ -781,8 +781,8 @@ aff_element_new (gdouble x,
elem->v.prob = 1.0;
sprintf (buffer,"%d",count);
elem->name = g_strdup(buffer);
sprintf (buffer,"%d", count);
elem->name = g_strdup (buffer);
return elem;
}
......@@ -806,8 +806,8 @@ create_brush (IfsComposeVals *ifsvals,
gint *brush_size,
gdouble *brush_offset)
{
gint i,j;
gint ii,jj;
gint i, j;
gint ii, jj;
guchar *brush;
#ifdef DEBUG_BRUSH
gdouble totpix = 0.0;
......@@ -820,7 +820,7 @@ create_brush (IfsComposeVals *ifsvals,
brush = g_new (guchar, SQR (*brush_size));
for (i=0 ; i < *brush_size; i++)
for (i = 0; i < *brush_size; i++)
{
for (j = 0; j < *brush_size; j++)
{
......@@ -841,7 +841,7 @@ create_brush (IfsComposeVals *ifsvals,
pixel += (d < radius) / 100.0;
}
brush[i**brush_size + j] = 255.999 * pixel;
brush[i * *brush_size + j] = 255.999 * pixel;
#ifdef DEBUG_BRUSH
putchar(brush_chars[(gint)(pixel * 3.999)]);
......@@ -853,7 +853,7 @@ create_brush (IfsComposeVals *ifsvals,
#endif /* DEBUG_BRUSH */
}
#ifdef DEBUG_BRUSH
printf("Brush total / area = %f\n",totpix/SQR(ifsvals->subdivide));
printf ("Brush total / area = %f\n", totpix / SQR (ifsvals->subdivide));
#endif /* DEBUG_BRUSH */
return brush;
}
......@@ -883,8 +883,8 @@ ifs_render (AffElement **elements,
gdouble *fprob;
gint subdivide;
guchar *brush = NULL;
gint brush_size;
gdouble brush_offset;
gint brush_size = 1;
gdouble brush_offset = 0.0;
if (preview)
subdivide = 1;
......@@ -923,11 +923,11 @@ ifs_render (AffElement **elements,
psum = 0;
for (i = 0; i < num_elements; i++)
{
psum += (guint32) -1 * (fprob[i]/pt);
psum += (guint32) -1 * (fprob[i] / pt);
prob[i] = psum;
}
prob[i-1] = (guint32) -1; /* make sure we don't get bitten by roundoff */
prob[i - 1] = (guint32) -1; /* make sure we don't get bitten by roundoff */
/* create the brush */
if (!preview)
......@@ -1020,7 +1020,7 @@ ifs_render (AffElement **elements,
if (n_hits == 255)
continue;
m_pix = brush[jj*brush_size+ii];
m_pix = brush[jj * brush_size + ii];
if (!m_pix)
continue;
nhits[index] = ++n_hits;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment