示例#1
0
static void RAPHAEL_Polygon(int n, double *x, double *y, const pGEcontext gc,
		pDevDesc dev) {

	DOCDesc *pd = (DOCDesc *) dev->deviceSpecific;
	int i;
	for (i = 1; i < n; i++) {
		DOC_ClipLine(x[i-1], y[i-1], x[i], y[i], dev);
		if( i < 2 ){
			x[i-1] = pd->clippedx0;
			y[i-1] = pd->clippedy0;
		}
		x[i] = pd->clippedx1;
		y[i] = pd->clippedy1;
	}

	int idx = get_and_increment_idx(dev);
	register_element( dev);

	fprintf(pd->dmlFilePointer, "var elt_%d = %s.path(\"", idx, pd->objectname );
	fprintf(pd->dmlFilePointer, "M %.0f %.0f", x[0], y[0]);

	for (i = 1; i < n; i++) {
		fprintf(pd->dmlFilePointer, "L %.0f %.0f", x[i], y[i]);
	}

	fputs("Z\");\n", pd->dmlFilePointer );

	RAPHAEL_SetLineSpec(dev, gc, idx);
	RAPHAEL_SetFillColor(dev, gc, idx);

	fflush(pd->dmlFilePointer);

}
示例#2
0
static void RAPHAEL_Line(double x1, double y1, double x2, double y2,
		const pGEcontext gc, pDevDesc dev) {
	DOCDesc *pd = (DOCDesc *) dev->deviceSpecific;

	DOC_ClipLine(x1, y1, x2, y2, dev);
	x1 = pd->clippedx0;y1 = pd->clippedy0;
	x2 = pd->clippedx1;y2 = pd->clippedy1;

	if (gc->lty > -1 && gc->lwd > 0.0 ){



		int idx = get_and_increment_idx(dev);
		register_element( dev);
		fprintf(pd->dmlFilePointer, "var elt_%d = %s.path(\"", idx, pd->objectname );
		fprintf(pd->dmlFilePointer, "M %.0f %.0f", x1, y1);
		fprintf(pd->dmlFilePointer, "L %.0f %.0f", x2, y2);
		fputs("\");\n", pd->dmlFilePointer );

		RAPHAEL_SetLineSpec(dev, gc, idx);

		fflush(pd->dmlFilePointer);
	}

	//return;
}
示例#3
0
static void PPTX_Line(double x1, double y1, double x2, double y2,
		const pGEcontext gc, pDevDesc dev) {
	DOCDesc *pd = (DOCDesc *) dev->deviceSpecific;
	int idx = get_and_increment_idx(dev);

	double maxx = 0, maxy = 0;
	double minx = 0, miny = 0;

	DOC_ClipLine(x1, y1, x2, y2, dev);
	x1 = pd->clippedx0;y1 = pd->clippedy0;
	x2 = pd->clippedx1;y2 = pd->clippedy1;

	if (x2 > x1) {
		maxx = x2;
		minx = x1;
	} else {
		maxx = x1;
		minx = x2;
	}
	if (y2 > y1) {
		maxy = y2;
		miny = y1;
	} else {
		maxy = y1;
		miny = y2;
	}

	fputs(pptx_elt_tag_start, pd->dmlFilePointer );
	if( pd->editable < 1 )
		fprintf(pd->dmlFilePointer,
			"<p:nvSpPr><p:cNvPr id=\"%d\" name=\"Line %d\" />%s</p:nvSpPr>", idx, idx, pptx_lock_properties);
	else fprintf(pd->dmlFilePointer,
		"<p:nvSpPr><p:cNvPr id=\"%d\" name=\"Line %d\" />%s</p:nvSpPr>", idx, idx, pptx_unlock_properties);

	fputs( "<p:spPr><a:xfrm>", pd->dmlFilePointer );
	fprintf(pd->dmlFilePointer, "<a:off x=\"%.0f\" y=\"%.0f\"/>"
			, p2e_(pd->offx + minx), p2e_(pd->offy + miny));
	fprintf(pd->dmlFilePointer, "<a:ext cx=\"%.0f\" cy=\"%.0f\"/>", p2e_(maxx-minx), p2e_(maxy-miny));

	fputs( "</a:xfrm><a:custGeom><a:avLst />", pd->dmlFilePointer );
	fputs( "<a:pathLst>", pd->dmlFilePointer );
	fprintf(pd->dmlFilePointer, "<a:path w=\"%.0f\" h=\"%.0f\">", p2e_(maxx-minx), p2e_(maxy-miny));
	fprintf(pd->dmlFilePointer,
			"<a:moveTo><a:pt x=\"%.0f\" y=\"%.0f\" /></a:moveTo>", p2e_(x1 - minx), p2e_(y1 - miny) );
	fprintf(pd->dmlFilePointer,
			"<a:lnTo><a:pt x=\"%.0f\" y=\"%.0f\" /></a:lnTo>", p2e_(x2 - minx), p2e_(y2 - miny));
	fputs( "</a:path></a:pathLst>", pd->dmlFilePointer );
	fputs( "</a:custGeom>", pd->dmlFilePointer );
	DML_SetLineSpec(dev, gc);
	fputs( "</p:spPr>", pd->dmlFilePointer );

	fputs( "<p:txBody><a:bodyPr /><a:lstStyle /><a:p/></p:txBody>", pd->dmlFilePointer );
	fputs(pptx_elt_tag_end, pd->dmlFilePointer );
//	fprintf(pd->dmlFilePointer, "\n");

	fflush(pd->dmlFilePointer);

	//return;
}
示例#4
0
static void PPTX_Polygon(int n, double *x, double *y, const pGEcontext gc,
		pDevDesc dev) {

	DOCDesc *pd = (DOCDesc *) dev->deviceSpecific;
	int idx = get_and_increment_idx(dev);
	int i;
	double maxx = 0, maxy = 0;

	for (i = 0; i < n; i++) {
		if (x[i] > maxx)
			maxx = x[i];
		if (y[i] > maxy)
			maxy = y[i];
	}
	double minx = maxx, miny = maxy;

	for (i = 0; i < n; i++) {
		if (x[i] < minx)
			minx = x[i];
		if (y[i] < miny)
			miny = y[i];
	}

	DOC_ClipLine(minx, miny, maxx, maxy, dev);
	minx = pd->clippedx0;miny = pd->clippedy0;
	maxx = pd->clippedx1;maxy = pd->clippedy1;

	for (i = 1; i < n; i++) {
		DOC_ClipLine(x[i-1], y[i-1], x[i], y[i], dev);
		if( i < 2 ){
			x[i-1] = pd->clippedx0;
			y[i-1] = pd->clippedy0;
		}
		x[i] = pd->clippedx1;
		y[i] = pd->clippedy1;
	}


	fputs(pptx_elt_tag_start, pd->dmlFilePointer );

	if( pd->editable < 1 )
		fprintf(pd->dmlFilePointer,
			"<p:nvSpPr><p:cNvPr id=\"%d\" name=\"Polygon form %d\" />%s</p:nvSpPr>", idx, idx, pptx_lock_properties);
	else fprintf(pd->dmlFilePointer,
			"<p:nvSpPr><p:cNvPr id=\"%d\" name=\"Polygon form %d\" />%s</p:nvSpPr>", idx, idx, pptx_unlock_properties);
	
	fputs("<p:spPr><a:xfrm>", pd->dmlFilePointer );
	fprintf(pd->dmlFilePointer, "<a:off x=\"%.0f\" y=\"%.0f\"/>",
			p2e_(pd->offx + minx), p2e_(pd->offy + miny));
	fprintf(pd->dmlFilePointer, "<a:ext cx=\"%.0f\" cy=\"%.0f\"/>", p2e_(maxx-minx), p2e_(maxy-miny));
	fputs("</a:xfrm><a:custGeom><a:avLst />", pd->dmlFilePointer );
	fputs("<a:pathLst>", pd->dmlFilePointer );
	fprintf(pd->dmlFilePointer, "<a:path w=\"%.0f\" h=\"%.0f\">", p2e_(maxx-minx), p2e_(maxy-miny));
	fprintf(pd->dmlFilePointer,
			"<a:moveTo><a:pt x=\"%.0f\" y=\"%.0f\" /></a:moveTo>",
			p2e_(x[0] - minx), p2e_(y[0] - miny));
	for (i = 1; i < n; i++) {
		fprintf(pd->dmlFilePointer,
				"<a:lnTo><a:pt x=\"%.0f\" y=\"%.0f\" /></a:lnTo>",
				p2e_(x[i] - minx), p2e_(y[i] - miny));
	}
	fputs("<a:close/></a:path></a:pathLst>", pd->dmlFilePointer );
	fputs("</a:custGeom>", pd->dmlFilePointer );
	DML_SetFillColor(dev, gc);
	DML_SetLineSpec(dev, gc);
	fputs("</p:spPr>", pd->dmlFilePointer );

	fprintf(pd->dmlFilePointer,
			"<p:txBody><a:bodyPr /><a:lstStyle /><a:p/></p:txBody>");
	fputs(pptx_elt_tag_end, pd->dmlFilePointer );
	fprintf(pd->dmlFilePointer, "\n");
	fflush(pd->dmlFilePointer);

}