static void arrow_type_dot(GVJ_t * job, pointf p, pointf u, int flag)
{
double r;
+ pointf AF[2];
r = sqrt(u.x * u.x + u.y * u.y) / 2.;
- p.x += u.x / 2.;
- p.y += u.y / 2.;
- gvrender_ellipse(job, p, r, r, !(flag & ARR_MOD_OPEN));
+ AF[0].x = p.x + u.x / 2. - r;
+ AF[0].y = p.y + u.y / 2. - r;
+ AF[1].x = p.x + u.x / 2. + r;
+ AF[1].y = p.y + u.y / 2. + r;
+ gvrender_ellipse(job, AF, 2, !(flag & ARR_MOD_OPEN));
}
static pointf arrow_gen_type(GVJ_t * job, pointf p, pointf u, int flag)
point imagesize;
pointf P, Q, R;
pointf *vertices;
- char *p;
+ char *p, *sfile;
double temp, alpha, beta, gamma, delta;
double orientation, distortion, skew;
double sectorangle, sidelength, skewdist, gdistortion, gskew;
* function.
*/
if (streq(ND_shape(n)->name, "custom")) {
- char *sfile = agget(n, "shapefile");
+ sfile = agget(n, "shapefile");
imagesize = gvusershape_size(n->graph, sfile);
if ((imagesize.x == -1) && (imagesize.y == -1)) {
agerr(AGWARN,
}
}
}
- else {
- char *sfile = agget(n, "image");
+ else if ((sfile = agget(n, "image"))) {
imagesize = gvusershape_size(n->graph, sfile);
if ((imagesize.x == -1) && (imagesize.y == -1)) {
agerr(AGWARN,
if (peripheries < 1)
outp = 1;
if (sides < 3) { /* ellipses */
- sides = 1;
- vertices = N_NEW(outp, pointf);
+ sides = 2;
+ vertices = N_NEW(outp * sides, pointf);
P.x = bb.x / 2.;
P.y = bb.y / 2.;
- vertices[0] = P;
+ vertices[1] = P;
+ vertices[0].x = -P.x;
+ vertices[0].y = -P.y;
if (peripheries > 1) {
for (j = 1; j < peripheries; j++) {
P.x += GAP;
/* get coords of innermost periphery */
for (i = 0; i < sides; i++) {
P = vertices[i];
- AF[i].x = P.x * xsize;
- AF[i].y = P.y * ysize;
- if (sides > 2) {
- AF[i].x += (double)ND_coord_i(n).x;
- AF[i].y += (double)ND_coord_i(n).y;
- }
+ AF[i].x = P.x * xsize + (double)ND_coord_i(n).x;
+ AF[i].y = P.y * ysize + (double)ND_coord_i(n).y;
}
/* lay down fill first */
if (filled && pfilled) {
if (sides <= 2) {
- pointf PF;
-
- P2PF(ND_coord_i(n), PF);
- gvrender_ellipse(job, PF, AF[0].x, AF[0].y, filled);
+ gvrender_ellipse(job, AF, sides, filled);
if (style & DIAGONALS) {
Mcircle_hack(job, n);
}
gvrender_polygon(job, AF, sides, filled);
}
}
- if (sides <=2) {
- pointf PF;
-
- P2PF(ND_coord_i(n), PF);
- AF[1].x = PF.x - AF[0].x;
- AF[1].y = PF.y - AF[0].y;
- AF[0].x += PF.x;
- AF[0].y += PF.y;
- }
- gvrender_usershape(job, name, AF, 2, filled, FALSE);
+ gvrender_usershape(job, name, AF, sides, filled, FALSE);
filled = FALSE; /* with user shapes, we have done the fill if needed */
}
for (j = 0; j < peripheries; j++) {
for (i = 0; i < sides; i++) {
P = vertices[i + j * sides];
- AF[i].x = P.x * xsize;
- AF[i].y = P.y * ysize;
- if (sides > 2) {
- AF[i].x += (double)ND_coord_i(n).x;
- AF[i].y += (double)ND_coord_i(n).y;
- }
+ AF[i].x = P.x * xsize + (double)ND_coord_i(n).x;
+ AF[i].y = P.y * ysize + (double)ND_coord_i(n).y;
}
if (sides <= 2) {
- pointf PF;
-
- P2PF(ND_coord_i(n), PF);
- gvrender_ellipse(job, PF, AF[0].x, AF[0].y, filled);
+ gvrender_ellipse(job, AF, sides, filled);
if (style & DIAGONALS) {
Mcircle_hack(job, n);
}
extern void gvrender_set_penwidth(GVJ_t * job, double penwidth);
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, pointf p,
- double rx, double ry, boolean filled);
+ extern void gvrender_ellipse(GVJ_t * job, pointf * AF, int n, boolean filled);
extern void gvrender_polygon(GVJ_t * job, pointf * AF, int n, boolean filled);
extern void gvrender_box(GVJ_t * job, boxf BF, boolean filled);
extern void gvrender_beziercurve(GVJ_t * job, pointf * AF, int n,
#endif
}
-void gvrender_ellipse(GVJ_t * job, pointf pf, double rx, double ry, boolean filled)
+void gvrender_ellipse(GVJ_t * job, pointf * pf, int n, boolean filled)
{
gvrender_engine_t *gvre = job->render.engine;
pointf af[2];
/* center */
- af[0] = pf;
+ af[0].x = (pf[0].x + pf[1].x)/2.;
+ af[0].y = (pf[0].y + pf[1].y)/2.;
/* corner */
- af[1].x = pf.x + rx;
- af[1].y = pf.y + ry;
+ af[1] = pf[1];
if (! (job->flags & GVRENDER_DOES_TRANSFORM))
gvrender_ptf_A(job, af, af, 2);
codegen_t *cg = job->codegen;
if (cg && cg->ellipse) {
- point p;
+ pointf af[2];
+ point p, r;
- PF2P(pf, p);
- cg->ellipse(p, ROUND(rx), ROUND(ry), filled);
+ /* center */
+ af[0].x = (pf[0].x + pf[1].x)/2.;
+ af[0].y = (pf[0].y + pf[1].y)/2.;
+ /* radius */
+ af[1].x = pf[1].x - af[0].x;
+ af[1].y = pf[1].y - af[0].y;
+
+ PF2P(af[0], p);
+ PF2P(af[1], r);
+ cg->ellipse(p, r.x, r.y, filled);
}
}
#endif