示例#1
0
static void svg_bzptarray(GVJ_t * job, pointf * A, int n)
{
    int i;
    char c;

    c = 'M';			/* first point */
#if EDGEALIGN
    if (A[0].x <= A[n-1].x) {
#endif
	for (i = 0; i < n; i++) {
	    gvprintf(job, "%c%g,%g", c, A[i].x, -A[i].y);
	    if (i == 0)
		c = 'C';		/* second point */
	    else
		c = ' ';		/* remaining points */
	}
#if EDGEALIGN
    } else {
	for (i = n-1; i >= 0; i--) {
	    gvprintf(job, "%c%g,%g", c, A[i].x, -A[i].y);
	    if (i == 0)
		c = 'C';		/* second point */
	    else
		c = ' ';		/* remaining points */
	}
    }
#endif
}
示例#2
0
/* doSphere:
 * Output sphere in VRML for point nodes.
 */
static void 
doSphere (GVJ_t *job, node_t *n, pointf p, double z, double rx, double ry)
{
    obj_state_t *obj = job->obj;

//    if (!(strcmp(cstk[SP].fillcolor, "transparent"))) {
//	return;
//    }
 
    gvputs(job,   "Transform {\n");
    gvprintf(job, "  translation %.3f %.3f %.3f\n", p.x, p.y, z);
    gvprintf(job, "  scale %.3f %.3f %.3f\n", rx, rx, rx);
    gvputs(job,   "  children [\n");
    gvputs(job,   "    Transform {\n");
    gvputs(job,   "      children [\n");
    gvputs(job,   "        Shape {\n");
    gvputs(job,   "          geometry Sphere { radius 1.0 }\n");
    gvputs(job,   "          appearance Appearance {\n");
    gvputs(job,   "            material Material {\n");
    gvputs(job,   "              ambientIntensity 0.33\n");
    gvprintf(job, "              diffuseColor %.3f %.3f %.3f\n", 
	    obj->pencolor.u.rgba[0] / 255.,
	    obj->pencolor.u.rgba[1] / 255.,
	    obj->pencolor.u.rgba[2] / 255.);
    gvputs(job,   "            }\n");
    gvputs(job,   "          }\n");
    gvputs(job,   "        }\n");
    gvputs(job,   "      ]\n");
    gvputs(job,   "    }\n");
    gvputs(job,   "  ]\n");
    gvputs(job,   "}\n");
}
示例#3
0
static void
doSegment (GVJ_t *job, pointf* A, pointf p0, double z0, pointf p1, double z1)
{
    obj_state_t *obj = job->obj;
    double d1, d0;
    double delx, dely, delz;

    delx = p0.x - p1.x;
    dely = p0.y - p1.y;
    delz = z0 - z1;
    EdgeLen = sqrt(delx*delx + dely*dely + delz*delz);
    d0 = DIST(A[0],p0);
    d1 = DIST(A[3],p1);
    CylHt = EdgeLen - d0 - d1;
    TailHt = HeadHt = 0;

    IsSegment = 1;
    gvputs(job,   "Transform {\n");
    gvputs(job,   "  children [\n");
    gvputs(job,   "    Shape {\n");
    gvputs(job,   "      geometry Cylinder {\n"); 
    gvputs(job,   "        bottom FALSE top FALSE\n"); 
    gvprintf(job, "        height %.3f radius %.3f }\n", CylHt, obj->penwidth);
    gvputs(job,   "      appearance Appearance {\n");
    gvputs(job,   "        material Material {\n");
    gvputs(job,   "          ambientIntensity 0.33\n");
    gvprintf(job, "          diffuseColor %.3f %.3f %.3f\n",
	    obj->pencolor.u.rgba[0] / 255.,
	    obj->pencolor.u.rgba[1] / 255.,
	    obj->pencolor.u.rgba[2] / 255.);
    gvputs(job,   "        }\n");
    gvputs(job,   "      }\n");
    gvputs(job,   "    }\n");
}
	void Char::Print(GVJ_t* job) const
	{
		gvputs(job, "<Char>\n");
		gvprintf(job, "<Color>#%02X%02X%02X</Color>\n", _red, _green, _blue);
		gvprintf(job, "<Size>%f</Size>\n", _size * job->scale.x * INCHES_PER_POINT);	/* scale font size, VDX uses inches */
		gvputs(job, "</Char>\n");
	}
static void mif_color(GVJ_t * job, int i)
{
    if (isupper(mif_colors[i].name[0]))
	gvprintf(job, "<Separation %d>\n", i);
    else
	gvprintf(job, "<ObColor `%s'>\n", mif_colors[i].name);
}
static void psgen_textspan(GVJ_t * job, pointf p, textspan_t * span)
{
    char *str;

    if (job->obj->pencolor.u.HSVA[3] < .5)
	return;  /* skip transparent text */

    ps_set_color(job, &(job->obj->pencolor));
    gvprintdouble(job, span->font->size);
    gvprintf(job, " /%s set_font\n", span->font->name);
    str = ps_string(span->str,isLatin1);
    switch (span->just) {
    case 'r':
        p.x -= span->size.x;
        break;
    case 'l':
        p.x -= 0.0;
        break;
    case 'n':
    default:
        p.x -= span->size.x / 2.0;
        break;
    }
    p.y += span->yoffset_centerline;
    gvprintpointf(job, p);
    gvputs(job, " moveto ");
    gvprintdouble(job, span->size.x);
    gvprintf(job, " %s alignedtext\n", str);
}
示例#7
0
static void pic_set_style(GVJ_t *job, char **s)
{
    const char *line, *p;
    char skip = 0;
    char buf[BUFSIZ];

    buf[0] = '\0';
    gvprintf(job, "define attrs%d %%", 0);
    while ((p = line = *s++)) {
        while (*p)
            p++;
        p++;
        while (*p) {
            if (!strcmp(line, "setlinewidth")) {        /* a hack to handle the user-defined (PS) style spec in proc3d.gv */
                long n = atol(p);

                sprintf(buf,
                        "oldlinethick = linethick;linethick = %ld * scalethickness / %.0f\n",
                        n, Fontscale);
                skip = 1;
            } else
                gvprintf(job, " %s", p);
            while (*p)
                p++;
            p++;
        }
        if (!skip)
            gvprintf(job, " %s", line);
        skip = 0;
    }
    gvprintf(job, " %%\n");
    gvprintf(job, "%s", buf);
}
示例#8
0
static void svg_begin_graph(GVJ_t * job)
{
    obj_state_t *obj = job->obj;

    gvputs(job, "<!--");
    if (agnameof(obj->u.g)[0]) {
	gvputs(job, " Title: ");
	gvputs(job, xml_string(agnameof(obj->u.g)));
    }
    gvprintf(job, " Pages: %d -->\n",
	     job->pagesArraySize.x * job->pagesArraySize.y);

    gvprintf(job, "<svg width=\"%dpt\" height=\"%dpt\"\n",
	     job->width, job->height);
    gvprintf(job, " viewBox=\"%.2f %.2f %.2f %.2f\"",
	job->canvasBox.LL.x,
	job->canvasBox.LL.y,
	job->canvasBox.UR.x,
	job->canvasBox.UR.y);
    /* namespace of svg */
    gvputs(job, " xmlns=\"http://www.w3.org/2000/svg\"");
    /* namespace of xlink */
    gvputs(job, " xmlns:xlink=\"http://www.w3.org/1999/xlink\"");
    gvputs(job, ">\n");
}
static void
ps_set_pen_style(GVJ_t *job)
{
    double penwidth = job->obj->penwidth;
    char *p, *line, **s = job->obj->rawstyle;

    gvprintdouble(job, penwidth);
    gvputs(job," setlinewidth\n");

    while (s && (p = line = *s++)) {
	if (strcmp(line, "setlinewidth") == 0)
	    continue;
	while (*p)
	    p++;
	p++;
	while (*p) {
            gvprintf(job,"%s ", p);
	    while (*p)
		p++;
	    p++;
	}
	if (strcmp(line, "invis") == 0)
	    job->obj->penwidth = 0;
	gvprintf(job, "%s\n", line);
    }
}
示例#10
0
static void mif_ptarray(GVJ_t * job, pointf * A, int n)
{
    int i;

    gvprintf(job, " <NumPoints %d>\n", n);
    for (i = 0; i < n; i++)
	gvprintf(job, " <Point %.2f %.2f>\n", A[i].x, A[i].y);
}
示例#11
0
static void write_linear_grad (GVJ_t * job, xdot_linear_grad* lg, state_t* sp)
{
    indent(job, sp->Level);
    gvprintf(job, "\"p0\": [%.03f,%.03f],\n", lg->x0, lg->y0); 
    indent(job, sp->Level);
    gvprintf(job, "\"p1\": [%.03f,%.03f],\n", lg->x1, lg->y1); 
    indent(job, sp->Level);
    write_stops (job, lg->n_stops, lg->stops, sp);
}
示例#12
0
static void write_radial_grad (GVJ_t * job, xdot_radial_grad* rg, state_t* sp)
{
    indent(job, sp->Level);
    gvprintf(job, "\"p0\": [%.03f,%.03f,%.03f],\n", rg->x0, rg->y0, rg->r0); 
    indent(job, sp->Level);
    gvprintf(job, "\"p1\": [%.03f,%.03f,%.03f],\n", rg->x1, rg->y1, rg->r1); 
    indent(job, sp->Level);
    write_stops (job, rg->n_stops, rg->stops, sp);
}
示例#13
0
static void write_graph(Agraph_t * g, GVJ_t * job, int top, state_t* sp)
{
    Agnode_t* np; 
    Agedge_t* ep; 
    int ncnt = 0;
    int ecnt = 0;
    int sgcnt = 0;
    int has_subgs;
    Dt_t* map;

    if (top) {
	map = dtopen (&intDisc, Dtoset);
	aginit(g, AGNODE, ID, sizeof(gvid_t), FALSE);
	aginit(g, AGEDGE, ID, sizeof(gvid_t), FALSE);
	aginit(g, AGRAPH, ID, -((int)sizeof(gvid_t)), FALSE);
	sgcnt = label_subgs(g, sgcnt, map);
	for (np = agfstnode(g); np; np = agnxtnode(g,np)) {
	    if (IS_CLUSTER(np)) {
		ND_gid(np) = lookup(map, agnameof(np));
	    }
	    else {
		ND_gid(np) = sgcnt + ncnt++;
	    }
	    for (ep = agfstout(g, np); ep; ep = agnxtout(g,ep)) {
		ED_gid(ep) = ecnt++;
	    }
	}
	dtclose(map);
    }

    indent(job, sp->Level++);
    gvputs(job, "{\n");
    write_hdr(g, job, top, sp);
    write_attrs((Agobj_t*)g, job, sp);
    if (top) {
	gvputs(job, ",\n");
	indent(job, sp->Level);
	gvprintf(job, "\"_subgraph_cnt\": %d", sgcnt);
    } else {
	gvputs(job, ",\n");
	indent(job, sp->Level);
	gvprintf(job, "\"_gvid\": %d", GD_gid(g));
    }
    has_subgs = write_subgs(g, job, top, sp);
    write_nodes (g, job, top, has_subgs, sp);
    write_edges (g, job, top, sp);
    gvputs(job, "\n");
    sp->Level--;
    indent(job, sp->Level);
    if (top)
	gvputs(job, "}\n");
    else
	gvputs(job, "}");
}
示例#14
0
/* usershape described by a postscript file */
static void lasi_loadimage_ps(GVJ_t * job, usershape_t *us, boxf b, boolean filled)
{
    assert(job);
    assert(us);
    assert(us->name);

    if (us->data) {
        if (us->datafree != ps_freeimage) {
            us->datafree(us);        /* free incompatible cache data */
            us->data = NULL;
            us->datafree = NULL;
            us->datasize = 0;
        }
    }

    if (!us->data) { /* read file into cache */
        int fd;
	struct stat statbuf;

	if (!gvusershape_file_access(us))
	    return;
	fd = fileno(us->f);
        switch (us->type) {
            case FT_PS:
            case FT_EPS:
		fstat(fd, &statbuf);
		us->datasize = statbuf.st_size;
#if HAVE_SYS_MMAN_H
		us->data = mmap(0, statbuf.st_size, PROT_READ, MAP_SHARED, fd, 0);
#else
		us->data = malloc(statbuf.st_size);
		read(fd, us->data, statbuf.st_size);
#endif
		us->must_inline = TRUE;
                break;
            default:
                break;
        }
        if (us->data)
            us->datafree = ps_freeimage;
	gvusershape_file_release(us);
    }

    if (us->data) {
        gvprintf(job, "gsave %g %g translate newpath\n",
		b.LL.x - (double)(us->x), b.LL.y - (double)(us->y));
        if (us->must_inline)
            epsf_emit_body(job, us);
        else
            gvprintf(job, "user_shape_%d\n", us->macro_id);
        gvprintf(job, "grestore\n");
    }
}
示例#15
0
static void write_stops (GVJ_t * job, int n_stops, xdot_color_stop* stp, state_t* sp)
{
    int i;

    gvprintf(job, "\"stops\": [");
    for (i = 0; i < n_stops; i++) {
	if (i > 0) gvprintf(job, ",");
	gvprintf(job, "{\"frac\": %.03f, \"color\": \"%s\"}",
	    stp[i].frac, stoj(stp[i].color, sp));
    }
    gvprintf(job, "]\n");
} 
示例#16
0
static void mif_style(GVJ_t * job, int filled)
{
    obj_state_t *obj = job->obj;

    gvputs(job, "style=\"fill:");
    if (filled)
	mif_color(job->obj->fillcolor);
    else
        gvputs(job, "none");

    gvputs(job, ";stroke:");
     


    while ((line = *s++)) {
	if (streq(line, "solid"))
	    pen = P_SOLID;
	else if (streq(line, "dashed"))
	    pen = P_DASHED;
	else if (streq(line, "dotted"))
	    pen = P_DOTTED;
	else if (streq(line, "invis"))
	    pen = P_NONE;
	else if (streq(line, "bold"))
	    penwidth = WIDTH_BOLD;
	else if (streq(line, "filled"))
	    fill = P_SOLID;
	else if (streq(line, "unfilled"))
	    fill = P_NONE;
	else {
	    agerr(AGERR,
		  "mif_style: unsupported style %s - ignoring\n",
		  line);
	}
    }

    fw = fa = "Regular";
    switch (cp->fontopt) {
    case BOLD:
	fw = "Bold";
	break;
    case ITALIC:
	fa = "Italic";
	break;
    }
    gvprintf(job, 
	    "<Font <FFamily `%s'> <FSize %.1f pt> <FWeight %s> <FAngle %s>>\n",
	    cp->fontfam, job->scale.x * cp->fontsz, fw, fa);

    gvprintf(job, "<Pen %d> <Fill %d> <PenWidth %d>\n",
	    job->pen, job->fill, job->penwidth);
}
static void psgen_end_job(GVJ_t * job)
{
    gvputs(job, "%%Trailer\n");
    if (job->render.id != FORMAT_EPS)
        gvprintf(job, "%%%%Pages: %d\n", job->common->viewNum);
    if (job->common->show_boxes == NULL)
        if (job->render.id != FORMAT_EPS)
	    gvprintf(job, "%%%%BoundingBox: %d %d %d %d\n",
	        job->boundingBox.LL.x, job->boundingBox.LL.y,
	        job->boundingBox.UR.x, job->boundingBox.UR.y);
    gvputs(job, "end\nrestore\n");
    gvputs(job, "%%EOF\n");
}
	/* output the hyperlink */
	void Hyperlink::Print(GVJ_t* job, unsigned int id, bool isDefault) const
	{
		gvprintf(job, "<Hyperlink ID='%d'>\n", id);
		if (_description)
			gvprintf(job, "<Description>%s</Description>\n", _description);
		if (_address)
			gvprintf(job, "<Address>%s</Address>\n", _address);
		if (_frame)
			gvprintf(job, "<Frame>%s</Frame>\n", _frame);
		if (isDefault)
			gvputs(job, "<Default>1</Default>\n");
		gvputs(job, "</Hyperlink>\n");
	}
示例#19
0
static void write_polyline (GVJ_t * job, xdot_polyline* polyline)
{
    int i;
    int cnt = polyline->cnt;
    xdot_point* pts = polyline->pts;

    gvprintf(job, "\"points\": [");
    for (i = 0; i < cnt; i++) {
	if (i > 0) gvprintf(job, ",");
	gvprintf(job, "[%.03f,%.03f]", pts[i].x, pts[i].y);
    }
    gvprintf(job, "]\n");
}
static void psgen_begin_page(GVJ_t * job)
{
    box pbr = job->pageBoundingBox;

    gvprintf(job, "%%%%Page: %d %d\n",
	    job->common->viewNum + 1, job->common->viewNum + 1);
    if (job->common->show_boxes == NULL)
        gvprintf(job, "%%%%PageBoundingBox: %d %d %d %d\n",
	    pbr.LL.x, pbr.LL.y, pbr.UR.x, pbr.UR.y);
    gvprintf(job, "%%%%PageOrientation: %s\n",
	    (job->rotation ? "Landscape" : "Portrait"));
    if (job->render.id == FORMAT_PS2)
        gvprintf(job, "<< /PageSize [%d %d] >> setpagedevice\n",
            pbr.UR.x, pbr.UR.y);
    gvprintf(job, "%d %d %d beginpage\n",
	    job->pagesArrayElem.x, job->pagesArrayElem.y, job->numPages);
    if (job->common->show_boxes == NULL)
        gvprintf(job, "gsave\n%d %d %d %d boxprim clip newpath\n",
	    pbr.LL.x, pbr.LL.y, pbr.UR.x-pbr.LL.x, pbr.UR.y-pbr.LL.y);
    gvprintf(job, "%g %g set_scale %d rotate %g %g translate\n",
	    job->scale.x, job->scale.y,
	    job->rotation,
	    job->translation.x, job->translation.y);

    /*  Define the size of the PS canvas  */
    if (job->render.id == FORMAT_PS2) {
	if (pbr.UR.x >= PDFMAX || pbr.UR.y >= PDFMAX)
	    job->common->errorfn("canvas size (%d,%d) exceeds PDF limit (%d)\n"
		  "\t(suggest setting a bounding box size, see dot(1))\n",
		  pbr.UR.x, pbr.UR.y, PDFMAX);
	gvprintf(job, "[ /CropBox [%d %d %d %d] /PAGES pdfmark\n",
		pbr.LL.x, pbr.LL.y, pbr.UR.x, pbr.UR.y);
    }
}
示例#21
0
/* usershape described by a member of a postscript library */
static void core_loadimage_pslib(GVJ_t * job, usershape_t *us, boxf b, boolean filled)
{
    int i;
    pointf AF[4];
    shape_desc *shape;

    assert(job);
    assert(us);
    assert(us->name);

    if ((shape = (shape_desc*)us->data)) {
	AF[0] = b.LL;
	AF[2] = b.UR;
	AF[1].x = AF[0].x;
	AF[1].y = AF[2].y;
	AF[3].x = AF[2].x;
	AF[3].y = AF[0].y;
        if (filled) {
//            ps_begin_context();
//            ps_set_color(S[SP].fillcolor);
            gvprintf(job, "[ ");
            for (i = 0; i < 4; i++)
                gvprintf(job, "%g %g ", AF[i].x, AF[i].y);
            gvprintf(job, "%g %g ", AF[0].x, AF[0].y);
            gvprintf(job, "]  %d true %s\n", 4, us->name);
//            ps_end_context();
        }
        gvprintf(job, "[ ");
        for (i = 0; i < 4; i++)
            gvprintf(job, "%g %g ", AF[i].x, AF[i].y);
        gvprintf(job, "%g %g ", AF[0].x, AF[0].y);
        gvprintf(job, "]  %d false %s\n", 4, us->name);
    }
}
示例#22
0
static void figptarray(GVJ_t *job, pointf * A, int n, int close)
{
    int i;
    point p;

    for (i = 0; i < n; i++) {
	PF2P(A[i],p);
        gvprintf(job, " %d %d", p.x, p.y);
    }
    if (close) {
	PF2P(A[0],p);
        gvprintf(job, " %d %d", p.x, p.y);
    }
    gvputs(job, "\n");
}
示例#23
0
static void svg_print_id_class(GVJ_t * job, char* id, char* idx, char* kind, void* obj)
{
    char* str;

    gvputs(job, "<g id=\"");
    gvputs(job, xml_string(id));
    if (idx)
	gvprintf (job, "_%s", xml_string(idx));
    gvprintf(job, "\" class=\"%s", kind);
    if ((str = agget(obj, "class")) && *str) {
	gvputs(job, " ");
	gvputs(job, xml_string(str));
    }
    gvputs(job, "\"");
}
示例#24
0
static void
vrml_bezier(GVJ_t *job, pointf * A, int n, int arrow_at_start, int arrow_at_end, int filled)
{
    obj_state_t *obj = job->obj;
    edge_t *e = obj->u.e;
    double fstz, sndz;
    pointf p1, V[4];
    int i, j, step;

    assert(e);

    fstz = Fstz = obj->tail_z; 
    sndz = Sndz = obj->head_z;
    if (straight(A,n)) {
	doSegment (job, A, gvrender_ptf(job, ND_coord(agtail(e))),Fstz,gvrender_ptf(job, ND_coord(aghead(e))),Sndz);
	return;
    }

    gvputs(job,   "Shape { geometry Extrusion  {\n");
    gvputs(job,   "  spine [");
    V[3] = A[0];
    for (i = 0; i + 3 < n; i += 3) {
	V[0] = V[3];
	for (j = 1; j <= 3; j++)
	    V[j] = A[i + j];
	for (step = 0; step <= BEZIERSUBDIVISION; step++) {
	    p1 = Bezier(V, 3, (double) step / BEZIERSUBDIVISION, NULL, NULL);
	    gvprintf(job, " %.3f %.3f %.3f", p1.x, p1.y,
		    interpolate_zcoord(job, p1, A[0], fstz, A[n - 1], sndz));
	}
    }
    gvputs(job,   " ]\n");
    gvprintf(job, "  crossSection [ %.3f %.3f, %.3f %.3f, %.3f %.3f, %.3f %.3f ]\n",
	    (obj->penwidth), (obj->penwidth), -(obj->penwidth),
	    (obj->penwidth), -(obj->penwidth), -(obj->penwidth),
	    (obj->penwidth), -(obj->penwidth));
    gvputs(job,   "}\n");
    gvprintf(job, " appearance DEF E%ld Appearance {\n", AGSEQ(e));
    gvputs(job,   "   material Material {\n");
    gvputs(job,   "   ambientIntensity 0.33\n");
    gvprintf(job, "   diffuseColor %.3f %.3f %.3f\n",
	    obj->pencolor.u.rgba[0] / 255.,
	    obj->pencolor.u.rgba[1] / 255.,
	    obj->pencolor.u.rgba[2] / 255.);
    gvputs(job,   "   }\n");
    gvputs(job,   " }\n");
    gvputs(job,   "}\n");
}
static void psgen_begin_graph(GVJ_t * job)
{
    obj_state_t *obj = job->obj;

    setupLatin1 = FALSE;

    if (job->common->viewNum == 0) {
        gvprintf(job, "%%%%Title: %s\n", agnameof(obj->u.g));
    	if (job->render.id != FORMAT_EPS)
            gvputs(job, "%%Pages: (atend)\n");
	else
	    gvputs(job, "%%Pages: 1\n");
        if (job->common->show_boxes == NULL) {
    	    if (job->render.id != FORMAT_EPS)
                gvputs(job, "%%BoundingBox: (atend)\n");
	    else
	        gvprintf(job, "%%%%BoundingBox: %d %d %d %d\n",
	            job->pageBoundingBox.LL.x, job->pageBoundingBox.LL.y,
	            job->pageBoundingBox.UR.x, job->pageBoundingBox.UR.y);
	}
        gvputs(job, "%%EndComments\nsave\n");
        /* include shape library */
        cat_libfile(job, job->common->lib, ps_txt);
	/* include epsf */
        epsf_define(job);
        if (job->common->show_boxes) {
            const char* args[2];
            args[0] = job->common->show_boxes[0];
            args[1] = NULL;
            cat_libfile(job, NULL, args);
        }
    }
    isLatin1 = (GD_charset(obj->u.g) == CHAR_LATIN1);
    /* We always setup Latin1. The charset info is always output,
     * and installing it is cheap. With it installed, we can then
     * rely on ps_string to convert UTF-8 characters whose encoding
     * is in the range of Latin-1 into the Latin-1 equivalent and
     * get the expected PostScript output.
     */
    if (!setupLatin1) {
	gvputs(job, "setupLatin1\n");	/* as defined in ps header */
	setupLatin1 = TRUE;
    }
    /*  Set base URL for relative links (for Distiller >= 3.0)  */
    if (obj->url)
	gvprintf(job, "[ {Catalog} << /URI << /Base (%s) >> >>\n"
		"/PUT pdfmark\n", obj->url);
}
示例#26
0
static void svg_polygon(GVJ_t * job, pointf * A, int n, int filled)
{
    int i, gid = 0;
    if (filled == GRADIENT) {
	gid = svg_gradstyle(job, A, n);
    } else if (filled == (RGRADIENT)) {
	gid = svg_rgradstyle(job, A, n);
    }
    gvputs(job, "<polygon");
    svg_grstyle(job, filled, gid);
    gvputs(job, " points=\"");
    for (i = 0; i < n; i++)
	gvprintf(job, "%g,%g ", A[i].x, -A[i].y);
    gvprintf(job, "%g,%g", A[0].x, -A[0].y);	/* because Adobe SVG is broken */
    gvputs(job, "\"/>\n");
}
示例#27
0
static void write_hdr(Agraph_t * g, GVJ_t * job, int top, state_t* sp)
{
    char *name;

    name = agnameof(g);
    indent(job, sp->Level);
    gvprintf(job, "\"name\": \"%s\"", stoj (name, sp));

    if (top) {
	gvputs(job, ",\n");
	indent(job, sp->Level);
	gvprintf(job, "\"directed\": %s,\n", (agisdirected(g)?"true":"false"));
	indent(job, sp->Level);
	gvprintf(job, "\"strict\": %s", (agisstrict(g)?"true":"false"));
    }
}
示例#28
0
static int write_subgs(Agraph_t * g, GVJ_t * job, int top, state_t* sp)
{
    Agraph_t* sg;
    int not_first = 0;

    sg = agfstsubg(g);
    if (!sg) return 0;
   
    gvputs(job, ",\n");
    indent(job, sp->Level++);
    if (top)
	gvputs(job, "\"objects\": [\n");
    else {
	gvputs(job, "\"subgraphs\": [\n");
	indent(job, sp->Level);
    }
    for (; sg; sg = agnxtsubg(sg)) {
	if (not_first) 
	    gvputs(job, ",\n");
	else
	    not_first = 1;
        if (top)
	    write_subg (sg, job, sp);
	else
	    gvprintf(job, "%d", GD_gid(sg));
    }
    if (!top) {
	sp->Level--;
	gvputs(job, "\n");
	indent(job, sp->Level);
	gvputs(job, "]");
    }

    return 1;
}
示例#29
0
static void
mif_begin_job(GVJ_t * job)
{
    gvprintf(job,
	"<MIFFile 3.00> # Generated by %s version %s (%s)\n",
	job->common->info[0], job->common->info[1], job->common->info[2]);
}
示例#30
0
static void
mif_begin_page(GVJ_t *job)
{
    gvprintf(job,
	    " <ArrowStyle <TipAngle 15> <BaseAngle 90> <Length %.1f> <HeadType Filled>>\n",
	    14 * job->scale.x);
}