当前位置: 首页>>代码示例>>C++>>正文


C++ CLine::SetAlpha方法代码示例

本文整理汇总了C++中CLine::SetAlpha方法的典型用法代码示例。如果您正苦于以下问题:C++ CLine::SetAlpha方法的具体用法?C++ CLine::SetAlpha怎么用?C++ CLine::SetAlpha使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CLine的用法示例。


在下文中一共展示了CLine::SetAlpha方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: NewBulletTracer

void CParticleEngine::NewBulletTracer(int x1, int y1, int x2, int y2, float intensity)
{
	int orderedTracerLength = sqrt((x2 - x1)*(x2 - x1) + (y2 - y1) * (y2 - y1));
	int createdTracerLength = 0;
	bool firstLine = true;
	float gradient = (float)(y2 - y1) / (float)(x2 - x1);
	float lineSegmentLength = standardLineSegmentLength * intensity;
	int loopNumber = 0;

	//create a bunch of lines with decreasing color and alpha intensity 
	while (createdTracerLength < orderedTracerLength)
	{
		float angle = atan2(y2 - y1, x2 - x1);
		float cosAngle = cos(angle);
		float sinAngle = sin(angle);
		CLine * line = new CLine();
		
		if (firstLine)
		{
			firstLine = false;
			line->x1 = x1;
			line->y1 = y1;
		}
		else
		{
			//take first point coordinates from last line's second point coordinates
			line->x1 = lineVector.at(lineVector.size() - 1)->x2 + cosAngle/abs(cosAngle);
			line->y1 = lineVector.at(lineVector.size() - 1)->y2 + sinAngle/abs(sinAngle);

		}
		 
		if (createdTracerLength + lineSegmentLength > orderedTracerLength) //last line is shorter
		{
			lineSegmentLength = orderedTracerLength - createdTracerLength;
		}
		/*x = old_x + length * cos(alpha);
		y = old_y + length * sin(alpha);*/

		//calculate x2 and y2
		
		line->x2 = line->x1 + lineSegmentLength * cosAngle;
		line->y2 = line->y1 + lineSegmentLength * sinAngle;
		
		createdTracerLength += lineSegmentLength;

		//set color values according to intensity
		line->SetRGB(255, 255, 255 - (intensity*150.0f) + loopNumber * (8.0f / intensity));
		line->SetAlpha(160 + (intensity*50.0f) - (loopNumber * (5.0f / intensity)));
		line->SetAlphaLossPerMs(1.3f - intensity * 2);
		loopNumber++;
		lineVector.push_back(line);
	}
}
开发者ID:scaepz,项目名称:Shapist,代码行数:53,代码来源:ParticleEngine.cpp


注:本文中的CLine::SetAlpha方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。