Exemplo n.º 1
0
INT32 GBlend::FlattenSplit( POINT P0, POINT P1, POINT P2, POINT P3 )
{
	POINT L1, L2, M, R1, R2 ;
	L1.x = (P0.x + P1.x)/2;
	L1.y = (P0.y + P1.y)/2;
	L2.x = (P0.x + 2*P1.x + P2.x)/4;
	L2.y = (P0.y + 2*P1.y + P2.y)/4;
	 M.x = (P0.x + 3*P1.x + 3*P2.x + P3.x)/8;
	 M.y = (P0.y + 3*P1.y + 3*P2.y + P3.y)/8;
	R1.x = (P1.x + 2*P2.x + P3.x)/4;
	R1.y = (P1.y + 2*P2.y + P3.y)/4;
	R2.x = (P2.x + P3.x)/2;
	R2.y = (P2.y + P3.y)/2;
    return BezierLength(P0, L1, L2, M) + BezierLength(M, R1, R2, P3) ;
}
Exemplo n.º 2
0
// --------------------------------------------------
int
DrawShape::BezierPoints(BPoint *curve, int n) {
	float len = BezierLength(curve, n);
	if (len <= kMinBezierPoints) return kMinBezierPoints;
	if (len >  kMaxBezierPoints) return kMaxBezierPoints;
	return (int)len;
}
Exemplo n.º 3
0
BOOL GBlend::CalcPathLengths(
		PPOINT	Points,
		PBYTE	Types,
		UINT32	Length,
		PUINT32	Buffer,
		UINT32	BufferLength,
		PUINT32 &BufferEnd
	)
{
	UINT32 TotalLength = 0 ;
	BufferEnd = Buffer ;
    UINT32 i = 1 ;
    while ( i<Length )
    {
		if ( IsLine(Types[i]) )
		{
			*BufferEnd = length( Points[i-1],Points[i] ) ;
			i++ ;
		}
		else /* Curve */
		{
			*BufferEnd = BezierLength( Points[i-1],Points[i],Points[i+1],Points[i+2] ) ;
			i+=3 ;
    	}
		TotalLength += *BufferEnd++ ;
    }
	PUINT32 P = Buffer ;
	UINT32 Total = 0 ;
	while ( P<BufferEnd )
	{
		*P = ScaledDiv( *P, TotalLength ) ;
		Total += *P++ ;
	}
	if ( Total != 0x10000000 )
	{
		while ( *(--P)+0x10000000 <= Total )
		{ }
		*P -= Total-0x10000000 ;
	}
	return TRUE ;
}