int i, j, peripheries, sides, style;
pointf P, *vertices;
static point *A;
+ static pointf *AF;
static int A_size;
bool filled;
char *color;
if (A_size < sides) {
A_size = sides + 5;
A = ALLOC(A_size, A, point);
+ AF = ALLOC(A_size, AF, pointf);
}
ND_label(n)->p = ND_coord_i(n);
for (j = 0; j < peripheries; j++) {
for (i = 0; i < sides; i++) {
P = vertices[i + j * sides];
+ AF[i].x = P.x * xsize / 16.;
+ AF[i].y = P.y * ysize / 16.;
+ if (sides > 2) {
+ AF[i].x += ND_coord_i(n).x;
+ AF[i].y += ND_coord_i(n).y;
+ }
/* simple rounding produces random results around .5
* this trick should clip off the random part.
* (note xsize/ysize prescaled by 16.0 above) */
}
}
if (sides <= 2) {
- gvrender_ellipse(job, ND_coord_i(n), A[0].x, A[0].y, filled);
+ pointf PF;
+
+ P2PF(ND_coord_i(n), PF);
+ gvrender_ellipsef(job, PF, AF[0].x, AF[0].y, filled);
if (style & DIAGONALS) {
Mcircle_hack(job, n);
}
} else if (style & (ROUNDED | DIAGONALS)) {
node_round_corners(job, n, A, sides, style);
} else {
- gvrender_polygon(job, A, sides, filled);
+ gvrender_polygonf(job, AF, sides, filled);
}
/* fill innermost periphery only */
filled = FALSE;
extern void gvrender_set_pencolor(GVJ_t * job, char *name);
extern void gvrender_set_fillcolor(GVJ_t * job, char *name);
extern void gvrender_set_style(GVJ_t * job, char **s);
- extern void gvrender_ellipse(GVJ_t * job, point p, int rx, int ry,
- int filled);
- extern void gvrender_polygon(GVJ_t * job, point * A, int n,
- int filled);
+ extern void gvrender_ellipse(GVJ_t * job, point p, int rx, int ry, int filled);
+ extern void gvrender_ellipsef(GVJ_t * job, pointf p, double rx, double ry, int filled);
+ extern void gvrender_polygon(GVJ_t * job, point * A, int n, int filled);
+ extern void gvrender_polygonf(GVJ_t * job, pointf * AF, int n, int filled);
extern void gvrender_beziercurve(GVJ_t * job, pointf * AF, int n,
int arrow_at_start, int arrow_at_end, int);
extern void gvrender_polyline(GVJ_t * job, point * A, int n);
#endif
}
+void gvrender_ellipsef(GVJ_t * job, pointf pf, double rx, double ry, int filled)
+{
+ gvrender_engine_t *gvre = job->render.engine;
+
+ if (gvre && gvre->ellipse) {
+ if (job->style->pen != PEN_NONE) {
+ pointf af[2];
+
+ /* center */
+ af[0] = pf;
+ /* corner */
+ af[1].x = pf.x + rx;
+ af[1].y = pf.y + ry;
+ /* scale */
+ af[0] = gvrender_ptf(job, af[0]);
+ af[1] = gvrender_ptf(job, af[1]);
+ gvre->ellipse(job, af, filled);
+ }
+ }
+#ifndef DISABLE_CODEGENS
+ else {
+ codegen_t *cg = job->codegen;
+
+ if (cg && cg->ellipse) {
+ point p;
+
+ PF2P(pf, p);
+ cg->ellipse(p, ROUND(rx), ROUND(ry), filled);
+ }
+ }
+#endif
+}
+
void gvrender_ellipse(GVJ_t * job, point p, int rx, int ry, int filled)
{
gvrender_engine_t *gvre = job->render.engine;
#endif
}
+void gvrender_polygonf(GVJ_t * job, pointf * af, int n, int filled)
+{
+ int i;
+ gvrender_engine_t *gvre = job->render.engine;
+
+ if (gvre && gvre->polygon) {
+ if (job->style->pen != PEN_NONE) {
+ if (sizeAF < n) {
+ sizeAF = n+10;
+ AF = grealloc(AF, sizeAF * sizeof(pointf));
+ }
+ for (i = 0; i < n; i++)
+ AF[i] = gvrender_ptf(job, af[i]);
+ gvre->polygon(job, AF, n, filled);
+ }
+ }
+#ifndef DISABLE_CODEGENS
+ else {
+ codegen_t *cg = job->codegen;
+
+ if (sizeA < n) {
+ sizeA = n+10;
+ A = grealloc(A, sizeA * sizeof(point));
+ }
+ for (i = 0; i < n; i++)
+ PF2P(af[i], A[i]);
+ if (cg && cg->polygon)
+ cg->polygon(A, n, filled);
+ }
+#endif
+}
+
void gvrender_polygon(GVJ_t * job, point * A, int n, int filled)
{
gvrender_engine_t *gvre = job->render.engine;