Example #1
0
static void cubicBezRec(struct SVGParser* p,
						float x1, float y1, float x2, float y2,
						float x3, float y3, float x4, float y4,
						int level)
{
	float x12,y12,x23,y23,x34,y34,x123,y123,x234,y234,x1234,y1234;
	float d;

	if (level > 12) return;

	x12 = (x1+x2)*0.5f;
	y12 = (y1+y2)*0.5f;
	x23 = (x2+x3)*0.5f;
	y23 = (y2+y3)*0.5f;
	x34 = (x3+x4)*0.5f;
	y34 = (y3+y4)*0.5f;
	x123 = (x12+x23)*0.5f;
	y123 = (y12+y23)*0.5f;
	x234 = (x23+x34)*0.5f;
	y234 = (y23+y34)*0.5f;
	x1234 = (x123+x234)*0.5f;
	y1234 = (y123+y234)*0.5f;

	d = distPtSeg(x1234, y1234, x1,y1, x4,y4);
	if (level > 0 && d < p->tol*p->tol)
	{
		svgPathPoint(p, x1234, y1234);
		return;
	}

	cubicBezRec(p, x1,y1, x12,y12, x123,y123, x1234,y1234, level+1);
	cubicBezRec(p, x1234,y1234, x234,y234, x34,y34, x4,y4, level+1);
}
Example #2
0
void ofxSVGPathParser::cubicBezRec(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, int level)
{
	float x12,y12,x23,y23,x34,y34,x123,y123,x234,y234,x1234,y1234;
	float d;
	
	if (level > 12) return;
	
	x12 = (x1+x2)*0.5f;
	y12 = (y1+y2)*0.5f;
	x23 = (x2+x3)*0.5f;
	y23 = (y2+y3)*0.5f;
	x34 = (x3+x4)*0.5f;
	y34 = (y3+y4)*0.5f;
	x123 = (x12+x23)*0.5f;
	y123 = (y12+y23)*0.5f;
	x234 = (x23+x34)*0.5f;
	y234 = (y23+y34)*0.5f;
	x1234 = (x123+x234)*0.5f;
	y1234 = (y123+y234)*0.5f;
	
	d = distPtSeg(x1234, y1234, x1,y1, x4,y4);
	if (level > 0 && d < 1000)//tol*tol)
	{
		pathInstance->quadBezierTo( ofPoint(x4, y4), ofPoint(x2, y2), ofPoint(x3, y3) );//svgPathPoint(x1234, y1234);
		return;
	}
	
	cubicBezRec(x1,y1, x12,y12, x123,y123, x1234,y1234, level+1); 
	cubicBezRec(x1234,y1234, x234,y234, x34,y34, x4,y4, level+1); 
}
Example #3
0
static void cubicBez(struct SVGParser* p,
					 float x1, float y1, float cx1, float cy1,
					 float cx2, float cy2, float x2, float y2)
{
	cubicBezRec(p, x1,y1, cx1,cy1, cx2,cy2, x2,y2, 0);
	svgPathPoint(p, x2, y2);
}
Example #4
0
void ofxSVGPathParser::cubicBez(float x1, float y1, float cx1, float cy1, float cx2, float cy2, float x2, float y2)
{
	cubicBezRec(x1,y1, cx1,cy1, cx2,cy2, x2,y2, 0); 
	//svgPathPoint(x2, y2);
	//pathInstance->lineTo(x1, y1);
}
void ofxSVGPathParser::cubicBez(float x1, float y1, float cx1, float cy1, float cx2, float cy2, float x2, float y2)
{
	cubicBezRec(x1,y1, cx1,cy1, cx2,cy2, x2,y2, 0); 
	svgPathPoint(x2, y2);
}