22 static int cmp_double(
const void *aa,
const void *bb)
27 return *a > *
b ? 1 : *a < *
b ? -1 : 0;
30 static void fill(
double x0,
double x1,
double y)
32 int yi = (int)floor(y);
33 int xi0 = (int)floor(x0 + 0.5);
34 int xi1 = (int)floor(x1 + 0.5);
55 for (
x = xi0;
x < xi1;
x++)
59 static void line(
const struct vertex *p,
int n,
double y)
66 for (i = 1; i < n; i++) {
67 const struct vertex *p0 = &p[i - 1];
68 const struct vertex *p1 = &p[i];
76 tmp = p0, p0 = p1, p1 = tmp;
84 x = p1->x * (
y - p0->y) + p0->x * (p1->y -
y);
89 xs =
G_realloc(xs, max_x *
sizeof(
double));
95 qsort(xs, num_x,
sizeof(
double), cmp_double);
97 for (i = 0; i + 1 < num_x; i += 2)
98 fill(xs[i], xs[i + 1],
y);
101 static void poly(
const struct vertex *p,
int n)
111 for (i = 1; i < n; i++) {
128 for (
y = floor(y0 + 0.5) + 0.5;
y < y1;
y++)
void path_close(struct path *p)
void png_polygon(struct path *p)
Draw polygon.
GRASS png display driver - header file.