Пример #1
0
// ****************************************************************************
//
//  Function Name:	YFontInfo::operator*( )
//
//  Description:		Apply the transform to alter the FontInfo
//							This involves scaling the height by the transform.XScale
//							and changing the rotation by the transform XRotation
//
//  Returns:			Nothing
//
//  Exceptions:		Nothing
//
// ****************************************************************************
//
YFontInfo YFontInfo::operator*( const R2dTransform& transform ) const
	{
	YFontInfo		newFont	= *this;
	YAngle			rotation;
	YRealDimension	xScale;
	YRealDimension	yScale;
	transform.Decompose( rotation, xScale, yScale );
	if ( xScale < yScale )
		yScale = xScale;
	else
		xScale = yScale;
	newFont.height		= ::Abs( ::Round( (YRealDimension)height * yScale ) );
	newFont.width		= ::Abs( ::Round( (YRealDimension)width * xScale ) );
	newFont.angle		+= (YIntDegrees)Round( RadiansToDegrees( rotation ) );
	return newFont;
	}
Пример #2
0
// ****************************************************************************
//
// Function Name:			RPsd3RuledLineGraphic::RenderRails()
//
// Description:			Draws the rails of the Ruled Line
//
// Returns:					Nothing
//
// Exceptions:				None
//
// ****************************************************************************
void RPsd3RuledLineGraphic::RenderRails(RDrawingSurface* pDS, RPath* pPath, const RRealSize& rLineSize, const R2dTransform& rTransform, const RIntRect& rRender, const RColor& rMonoColor) const
{
	//	Make sure we have a rail (is this necessary?)
	if ( !m_pRail )
		return;

	//	Compute the inverse of the transform
	R2dTransform	invTransform( rTransform );
	invTransform.Invert( );
	YRealDimension	xScale;
	YRealDimension	yScale;
	YAngle			rotation;
	rTransform.Decompose( rotation, xScale, yScale );

	//	Compute the size of the right and left caps respectively (if they exist)
	YRealDimension	leftCapSize		= (m_pLeftCap!=NULL)?	rLineSize.m_dy * m_pLeftCap->GetAspectRatio( ) : 0.0;
	YRealDimension	rightCapSize	= (m_pRightCap!=NULL)?	rLineSize.m_dy * m_pRightCap->GetAspectRatio( )
														: ((m_fMirrorCaps)? leftCapSize : 0.0 );

	YRealDimension	halfLine	= rLineSize.m_dx / 2.0;
	if ( leftCapSize > halfLine )
		leftCapSize	= halfLine;
	if ( rightCapSize > halfLine)
		rightCapSize = halfLine;

	//	Count the number of rails needed
	YRealDimension yVariableLength( rLineSize.m_dx - leftCapSize - rightCapSize );
	YRealDimension	yNominalXDimension( rLineSize.m_dy * m_pRail->GetAspectRatio() );
	sLONG				sRailCount = ::GetRailCount(yVariableLength, yNominalXDimension );
	//
	//	If no rails are needed, we are done
	if (sRailCount == 0) return;

	// Compute the new rail sizes (the small and large ones)
	RRealSize	smallRailSize( yVariableLength / (YFloatType)sRailCount, rLineSize.m_dy );
	smallRailSize	*= rTransform;
	smallRailSize	= RRealSize( floor( smallRailSize.m_dx ), floor( smallRailSize.m_dy ) );
	RRealSize	largeRailSize( smallRailSize.m_dx+1.0, smallRailSize.m_dy+1.0 );
	//
	//	Re-expand to logical units
	smallRailSize	*= invTransform;
	largeRailSize	*= invTransform;
	//
	//	Reset the y dimension
	smallRailSize.m_dy = largeRailSize.m_dy = rLineSize.m_dy;

	//	What is the excess
	YIntDimension	smallSize	= sRailCount;
	YIntDimension	increment	= static_cast<YIntDimension>( (yVariableLength - (smallRailSize.m_dx * sRailCount)) * xScale) + 1;
	YRealDimension	xStartOffset	= 0.0;
	YIntDimension	excessCounter	= 0;

	TpsAssert( smallSize>=0, "Extra space is negative" );

	if (m_pLeftCap)
		xStartOffset	+= leftCapSize;
	
	RRealSize	rRailSize( rLineSize );
	for (int nRail = 0; nRail < sRailCount-1; ++nRail)
	{
		//	Create a transform and offset it to the proper location
		R2dTransform	renderTransform( rTransform );
		renderTransform.PreTranslate( xStartOffset, 0 );

		//	Add the extra to the excessCounter
		excessCounter	+= increment;
		if ( excessCounter >= smallSize )
		{
			rRailSize		= largeRailSize;//smallRailSize;
			excessCounter	-= smallSize;
		}
		else
			rRailSize	= smallRailSize;//largeRailSize;

		if (pDS) m_pRail->Render(*pDS, rRailSize, renderTransform, rRender, rMonoColor);
		if (pPath) m_pRail->GetOutlinePath(*pPath, rRailSize, renderTransform);

		xStartOffset	+= rRailSize.m_dx;
	}

	//	Render the last rail, but make sure it is large enough
	R2dTransform	tmpTransform( rTransform );
	tmpTransform.PreTranslate( xStartOffset, 0 );
	rRailSize.m_dx	= yVariableLength + leftCapSize - xStartOffset;
	if (pDS) m_pRail->Render(*pDS, rRailSize, tmpTransform, rRender, rMonoColor);
	if (pPath) m_pRail->GetOutlinePath(*pPath, rRailSize, tmpTransform);
}