Beispiel #1
0
void OnPath(Painter& sw)
{
	sw.Move(200, 300).Quadratic(400, 50, 600, 300).Quadratic(1000, 300).Stroke(1, Blue());
	for(int i = -1; i <= 16; i++) {
		sw.BeginOnPath(i / 15.0);
		sw.Move(0, -6).Line(6, 0).Line(0, 6).Close().Stroke(1, Black());
		sw.End();
	}
}
Beispiel #2
0
void RenderCharPath(const char* gbuf, unsigned total_size, Painter& sw, double xx, double yy)
{
	const char* cur_glyph = gbuf;
	const char* end_glyph = gbuf + total_size;
	
	while(cur_glyph < end_glyph) {
		const TTPOLYGONHEADER* th = (TTPOLYGONHEADER*)cur_glyph;
		const char* end_poly = cur_glyph + th->cb;
		const char* cur_poly = cur_glyph + sizeof(TTPOLYGONHEADER);
		sw.Move(xx + fx_to_dbl(th->pfxStart.x), yy - fx_to_dbl(th->pfxStart.y));
		while(cur_poly < end_poly) {
			const TTPOLYCURVE* pc = (const TTPOLYCURVE*)cur_poly;
			if (pc->wType == TT_PRIM_LINE)
				for(int i = 0; i < pc->cpfx; i++)
					sw.Line(xx + fx_to_dbl(pc->apfx[i].x), yy - fx_to_dbl(pc->apfx[i].y));
			if (pc->wType == TT_PRIM_QSPLINE) {
				int u;
				for (u = 0; u < pc->cpfx - 1; u++) { // Walk through points in spline
					POINTFX pnt_b = pc->apfx[u];     // B is always the current point
					POINTFX pnt_c = pc->apfx[u+1];
					if (u < pc->cpfx - 2) {          // If not on last spline, compute C
						*(int*)&pnt_c.x = (*(int*)&pnt_b.x + *(int*)&pnt_c.x) / 2;
						*(int*)&pnt_c.y = (*(int*)&pnt_b.y + *(int*)&pnt_c.y) / 2;
					}
					sw.Quadratic(xx + fx_to_dbl(pnt_b.x), yy - fx_to_dbl(pnt_b.y),
					             xx + fx_to_dbl(pnt_c.x), yy - fx_to_dbl(pnt_c.y));
				}
			}
			cur_poly += sizeof(WORD) * 2 + sizeof(POINTFX) * pc->cpfx;
		}
		sw.Close();
		cur_glyph += th->cb;
    }
}
Beispiel #3
0
void OnPathBee(Painter& sw)
{
	sw.Move(200, 300).Quadratic(400, 50, 600, 300).Quadratic(1000, 300).Stroke(1, Blue());
	for(int i = -1; i <= 16; i++) {
		sw.BeginOnPath(i / 15.0);
		sw.DrawImage(0, -TestImg::Bee().GetHeight() / 2, TestImg::Bee());
		sw.End();
	}
}
Beispiel #4
0
void OnTextPath(Painter& sw)
{
	sw.Text(50, 50, "Hello!", Roman(350)).Stroke(1, Black());
	for(int i = 0; i <= 100; i++) {
		sw.BeginOnPath(i / 100.0);
		sw.Move(0, -6).Line(6, 0).Line(0, 6).Fill(Red());
		sw.End();
	}
}
Beispiel #5
0
void Path(Painter& sw)
{
	sw.Translate(52, 52);
	for(int i = 0; i < 2; i++) {
		sw.Rectangle(20, 20, 60, 60);
		sw.Move(0, 0);
		sw.Cubic(99, 0,  50, 50,  99, 99);
		sw.Cubic(0, 99,  50, 50,  0, 0);
		sw.EvenOdd(i).Fill(Green());
		sw.Stroke(1, Black());
		sw.Translate(120, 0);
	}
}
Beispiel #6
0
void BigStroke(Painter& sw)
{
	int n = 0;
	double r = 400;
	int    i = 0;
	while(r > 5) {
		Pointf p = Polar(i * M_2PI / 400) * r + Pointf(400, 400);
		if(i)
			sw.Line(p);
		else
			sw.Move(p);
		sw.Line(Polar((i * M_2PI / 400 + M_2PI / 800)) * (r - 3) + Pointf(400, 400));
		n += 2;
		r = r - 0.01;
		i++;
	}
	sw.Stroke(1, Black());
	sw.Text(0, 0, "Elements: " + AsString(n), Arial(20)).Fill(Blue());
}
Beispiel #7
0
void Big(Painter& sw)
{
	int n = 0;
	double sgn = 1;
	for(int r = 400; r > 5; r -= 3) {
		for(int i = 0; i < 400; i++) {
			Pointf p = Polar(sgn * i * M_2PI / 400) * r + Pointf(400, 400);
			if(i)
				sw.Line(p);
			else
				sw.Move(p);
			sw.Line(Polar(sgn * (i * M_2PI / 400 + M_2PI / 800)) * (r - 6) + Pointf(400, 400));
			n += 2;
		}
		sw.Close();
		sgn = -sgn;
	}
	sw.Fill(Black());
	sw.Text(0, 0, "Elements: " + AsString(n), Arial(20)).Fill(Blue());
}
Beispiel #8
0
void InvRectPath(Painter& pw, const Rect& r)
{
	pw.Move(r.left, r.top).Line(r.left, r.bottom).Line(r.right, r.bottom).Line(r.right, r.top).Close();
}
Beispiel #9
0
	virtual void Move(Pointf p) {
		sw->Move(p);
	}
Beispiel #10
0
bool RenderOutline(const FT_Outline& outline, Painter& path, double xx, double yy)
{
	FT_Vector   v_last;
	FT_Vector   v_control;
	FT_Vector   v_start;
	FT_Vector*  point;
	FT_Vector*  limit;
	char*       tags;
	int   n;         // index of contour in outline
	char  tag;       // current point's state
	int   first = 0; // index of first point in contour
	for(n = 0; n < outline.n_contours; n++) {
		int  last = outline.contours[n];
		limit = outline.points + last;
		v_start = outline.points[first];
		v_last  = outline.points[last];
		v_control = v_start;
		point = outline.points + first;
		tags  = outline.tags  + first;
		tag   = FT_CURVE_TAG(tags[0]);
		if(tag == FT_CURVE_TAG_CUBIC) return false;
		if(tag == FT_CURVE_TAG_CONIC) {
			if(FT_CURVE_TAG(outline.tags[last]) == FT_CURVE_TAG_ON) {
				// start at last point if it is on the curve
				v_start = v_last;
				limit--;
			}
			else {
				// if both first and last points are conic,
				// start at their middle and record its position
				// for closure
				v_start.x = (v_start.x + v_last.x) / 2;
				v_start.y = (v_start.y + v_last.y) / 2;
				v_last = v_start;
			}
			point--;
			tags--;
		}
		path.Move(ft_dbl(v_start.x) + xx, -ft_dbl(v_start.y) + yy);
		while(point < limit) {
			point++;
			tags++;

			tag = FT_CURVE_TAG(tags[0]);
			switch(tag) {
			case FT_CURVE_TAG_ON:
				path.Line(ft_dbl(point->x) + xx, -ft_dbl(point->y) + yy);
				continue;
			case FT_CURVE_TAG_CONIC:
				v_control.x = point->x;
				v_control.y = point->y;
			Do_Conic:
				if(point < limit) {
					FT_Vector vec;
					FT_Vector v_middle;
					point++;
					tags++;
					tag = FT_CURVE_TAG(tags[0]);
					vec.x = point->x;
					vec.y = point->y;
					if(tag == FT_CURVE_TAG_ON) {
						path.Quadratic(ft_dbl(v_control.x) + xx, -ft_dbl(v_control.y) + yy,
						               ft_dbl(vec.x) + xx, -ft_dbl(vec.y) + yy);
						continue;
					}
					if(tag != FT_CURVE_TAG_CONIC) return false;
					v_middle.x = (v_control.x + vec.x) / 2;
					v_middle.y = (v_control.y + vec.y) / 2;
					path.Quadratic(ft_dbl(v_control.x) + xx, -ft_dbl(v_control.y) + yy,
					               ft_dbl(v_middle.x) + xx, -ft_dbl(v_middle.y) + yy);
					v_control = vec;
					goto Do_Conic;
				}
				path.Quadratic(ft_dbl(v_control.x) + xx, -ft_dbl(v_control.y) + yy,
				               ft_dbl(v_start.x) + xx, -ft_dbl(v_start.y) + yy);
				goto Close;

			default:
				FT_Vector vec1, vec2;
				if(point + 1 > limit || FT_CURVE_TAG(tags[1]) != FT_CURVE_TAG_CUBIC)
				    return false;
				vec1.x = point[0].x; 
				vec1.y = point[0].y;
				vec2.x = point[1].x; 
				vec2.y = point[1].y;
				point += 2;
				tags  += 2;
				if(point <= limit) {
					FT_Vector vec;
					vec.x = point->x;
					vec.y = point->y;
					path.Cubic(ft_dbl(vec1.x) + xx, -ft_dbl(vec1.y) + yy,
					           ft_dbl(vec2.x) + xx, -ft_dbl(vec2.y) + yy,
					           ft_dbl(vec.x) + xx, -ft_dbl(vec.y) + yy);
					continue;
				}
				path.Cubic(ft_dbl(vec1.x) + xx, -ft_dbl(vec1.y) + yy,
				           ft_dbl(vec2.x) + xx, -ft_dbl(vec2.y) + yy,
				           ft_dbl(v_start.x) + xx, -ft_dbl(v_start.y) + yy);
				goto Close;
			}
		}
	Close:
		path.Close();
		first = last + 1; 
    }
	return true;
}
Beispiel #11
0
	virtual void Paint(Painter &pntr,Size &sz){
		pntr.Move(0,0).Line(sz.cx,0).Line(sz.cx,sz.cy).Line(0,sz.cy).Close().Fill(White()).Stroke(5,Black());
		pntr.Move(0,0).Line(sz.cx,sz.cy).Stroke(5,Black());           
	}