示例#1
0
	void line(const Point2D& p1, const Point2D& p2, Style style = NONE)
	{
		tex += QString("\n\\draw%1 (%2,%3) -- (%4,%5);")
			.arg(style_tex(style))
			.arg(p1.x)
			.arg(p1.y)
			.arg(p2.x)
			.arg(p2.y);
		svg += QString("\n\t<line %1 x1=\"%2\" y1=\"%3\" x2=\"%4\" y2=\"%5\"/>")
			.arg(style_svg(style))
			.arg(scalex(p1.x))
			.arg(scaley(p1.y))
			.arg(scalex(p2.x))
			.arg(scaley(p2.y));
	}
示例#2
0
	void arc(const Point2D& p, double radius, double angle0, double angle1, Style style = NONE)
	{
		tex += QString("\n\\draw%1 (%2,%3) arc (%4:%5:%6);")
			.arg(style_tex(style))
			.arg(p.x)
			.arg(p.y)
			.arg(180/pi*angle0)
			.arg(180/pi*angle1)
			.arg(radius);
		Point2D p1 = p - Point2D::polar(radius, angle0) + Point2D::polar(radius, angle1);
		svg += QString("\n\t<path fill=\"none\" %1 d=\"M%2 %3 A%4 %5 0 0 0 %6 %7\"/>")
			.arg(style_svg(style))
			.arg(scalex(p.x))
			.arg(scaley(p.y))
			.arg(scale(radius))
			.arg(scale(radius))
			.arg(scalex(p1.x))
			.arg(scaley(p1.y));
	}
示例#3
0
	void path(const Point2D& p1, const Point2D& p2, const Point2D& p3, Style style = NONE)
	{
		tex += QString("\n\\draw%1 (%2,%3) -- (%4,%5) -- (%6,%7);")
			.arg(style_tex(style))
			.arg(p1.x)
			.arg(p1.y)
			.arg(p2.x)
			.arg(p2.y)
			.arg(p3.x)
			.arg(p3.y);
		svg += QString("\n\t<path %1 d=\"M%2 %3 L%4 %5 L%6 %7\" fill=\"none\"/>")
			.arg(style_svg(style))
			.arg(scalex(p1.x))
			.arg(scaley(p1.y))
			.arg(scalex(p2.x))
			.arg(scaley(p2.y))
			.arg(scalex(p3.x))
			.arg(scaley(p3.y));
	}
示例#4
0
	void dot(const Point2D& p, Style style = NONE)
	{
		tex += QString("\n\\draw%1 (%2,%3) circle(0.07);")
			.arg(style_tex(style | FILL))
			.arg(p.x)
			.arg(p.y);
		svg += QString("\n\t<circle %1 cx=\"%2\" cy=\"%3\" r=\"3\"/>")
			.arg(style_svg(style | FILL))
			.arg(scalex(p.x))
			.arg(scaley(p.y));
	}
示例#5
0
void doCircle(FILE *stream) {
  float cx, cy, r;
  int c;

  cx = getFloat(stream);
  cy = getFloat(stream);
  r = getFloat(stream);
  c = getColor(getNumber(stream));

  gdImageArc(image, viewx(cx), viewy(cy), 
	     scalex(r)*2, scaley(r)*2, 0, 360, c);
}
示例#6
0
void doFilledEllipse(FILE *stream) {
  float cx, cy, w, h;
  int c;

  cx = getFloat(stream);
  cy = getFloat(stream);
  w = getFloat(stream);
  h = getFloat(stream);
  c = getColor(getNumber(stream));

  gdImageFilledEllipse(image, viewx(cx), viewy(cy), 
		       scalex(w), scaley(h), c);
}
示例#7
0
	void math(const QString text, const Point2D& p, Style style = NONE)
	{
		tex += QString("\n\\node%1 at (%2,%3) {%4};")
			.arg(style_tex(style))
			.arg(p.x)
			.arg(p.y)
			.arg(text);
		html += QString("\n\t<div %1 style=\"left:%2px;top:%3px;\">%4</div>")
			.arg(style_math(style))
			.arg(scalex(p.x, style))
			.arg(scaley(p.y, style))
			.arg(text);
	}
示例#8
0
	void text(const QString text, const Point2D& p, Style style = NONE)
	{
		tex += QString("\n\\node%1 at (%2,%3) {%4};")
			.arg(style_tex(style))
			.arg(p.x)
			.arg(p.y)
			.arg(text);
		svg += QString("\n\t<text %1 x=\"%2\" y=\"%3\">%4</text>")
			.arg(style_svg(style | TEXT))
			.arg(scalex(p.x, style))
			.arg(scaley(p.y, style))
			.arg(text);
	}
示例#9
0
void doArc(FILE *stream) {
  float cx, cy, w, h;
  int s, e, c;

  cx = getFloat(stream);  // center x
  cy = getFloat(stream);  // center y
  w = getFloat(stream);   // width
  h = getFloat(stream);   // height
  s = getNumber(stream);   // start angle
  e = getNumber(stream);   // end angle
  c = getColor(getNumber(stream));   // color

  gdImageArc(image, viewx(cx), viewy(cy), 
	     scalex(w), scaley(h), s, e, c);
}
示例#10
0
void doFilledArc(FILE *stream) {
  float cx, cy, w, h, s;
  int e, c, style;

  cx = getFloat(stream);  // center x
  cy = getFloat(stream);  // center y
  w = getFloat(stream);   // width
  h = getFloat(stream);   // height
  s = getNumber(stream);   // start angle
  e = getNumber(stream);   // end angle
  c = getColor(getNumber(stream));   // color
  style = getNumber(stream);

  gdImageFilledArc(image, viewx(cx), viewy(cy), 
		   scalex(w), scaley(h), s, e, c, style);
}
示例#11
0
int tfont_render_glyph(int tx, int ty, char const *code)
{
	if(code == NULL) {
		return 0;
	}
	int advance = 0;
	int x = 0;
	int y = 0;
	int px = 0;
	int py = 0;
	while(*code)
	{
		char c = sgetc(&code);
		switch(c)
		{
			case 0:
			case -1:
				return scale(advance);
			case 'a':
				advance = sgetn(&code);
				break;
			case 'M':
				x = sgetn(&code);
				y = sgetn(&code);
				break;
			case 'm':
				x += sgetn(&code);
				y += sgetn(&code);
				break;
			case 'P':
				x = sgetn(&code);
				y = sgetn(&code);
				line(
					tx + scalex(px), 
					ty - scaley(py), 
					tx + scalex(x), 
					ty - scaley(y));
				break;
			case 'p':
				x += sgetn(&code);
				y += sgetn(&code);
				line(
					tx + scalex(px),
					ty - scaley(py), 
					tx + scalex(x), 
					ty - scaley(y));
				break;
			case 'd':
				dot(
					tx + scalex(x),
					ty - scaley(y));
				break;
			default:
#if TFONT_DEBUG
				printf("Unknown command: %c(%d)?\n", c, c);
#endif
				break;
		}
		px = x;
		py = y;
	}
	return scalex(advance);
}