12 static int cmp_int(
const void *aa,
const void *bb)
20 static void fill(
int x0,
int x1,
int y)
25 static void line(
const struct point *p,
int n,
int y)
32 for (i = 0; i <
n; i++) {
33 const struct point *p0 = &p[i];
34 const struct point *p1 = &p[i + 1];
35 const struct point *tmp;
43 tmp = p0, p0 = p1, p1 = tmp;
52 fx = (double)p1->
x * (fy - p0->y) + (double)p0->x * (p1->y - fy);
54 x = fx < -0x7fffffff ? -0x7fffffff :
55 fx > 0x7fffffff ? 0x7fffffff : (long)floor(fx + 0.5);
59 xs = G_realloc(xs, max_x *
sizeof(
int));
65 qsort(xs, num_x,
sizeof(
int), cmp_int);
67 for (i = 0; i + 1 < num_x; i += 2)
68 fill(xs[i], xs[i + 1], y);
71 static void poly(
const struct point *p,
int n)
81 for (i = 1; i <
n; i++) {
98 for (y = y0; y < y1; y++)
102 static void fill_polygon(
const int *xarray,
const int *yarray,
int count)
104 static struct point *points;
105 static int max_points;
108 if (max_points < count + 1) {
109 max_points = count + 1;
110 points = G_realloc(points,
sizeof(
struct point) * max_points);
113 for (i = 0; i <
count; i++) {
114 points[i].
x = xarray[i];
115 points[i].
y = yarray[i];
118 points[
count].
x = xarray[0];
119 points[
count].
y = yarray[0];
131 fill_polygon(xarray, yarray, number);
145 if (number > nalloc) {
147 xa = G_realloc(xa, (
size_t) nalloc *
sizeof(
int));
148 ya = G_realloc(ya, (
size_t) nalloc *
sizeof(
int));
151 xa[0] = xarray[0] +
cur_x;
152 ya[0] = yarray[0] +
cur_y;
154 for (i = 1; i < number; i++) {
155 xa[i] = xa[i - 1] + xarray[i];
156 ya[i] = ya[i - 1] + yarray[i];
void COM_Polygon_abs(const int *, const int *, int)
void(* Polygon_abs)(const int *, const int *, int)
void COM_Box_abs(int x1, int y1, int x2, int y2)
void COM_Polygon_rel(const int *, const int *, int)
void(* Polygon_rel)(const int *, const int *, int)