22static int cmp_double(
const void *aa,
const void *bb)
27 return *a > *
b ? 1 : *a < *
b ? -1 : 0;
30static 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);
38 if (yi >=
png.clip_bot || yi <
png.clip_top)
41 if (xi0 >
png.clip_rite)
44 if (xi1 <
png.clip_left)
47 if (xi0 <
png.clip_left)
50 if (xi1 >
png.clip_rite)
53 p = &
png.grid[yi *
png.width + xi0];
55 for (
x = xi0;
x < xi1;
x++)
56 *p++ =
png.current_color;
59static 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);
101static void poly(
const struct vertex *p,
int n)
111 for (i = 1; i < n; i++) {
119 if (y0 >
png.clip_bot || y1 <
png.clip_top)
122 if (y0 <
png.clip_top)
125 if (y1 >
png.clip_bot)
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.