Example #1
0
void CShapeEffectPainter::Paint (CG16bitImage &Dest, int x, int y, SViewportPaintCtx &Ctx)

//	Paint
//
//	Paint effect

	{
	//	Compute the desired rotation, length, and width

	int iLength = m_pCreator->GetLength() + Ctx.iTick * m_pCreator->GetLengthInc();
	int iWidth = m_pCreator->GetWidth() + Ctx.iTick * m_pCreator->GetWidthInc();
	int iRotation = (m_pCreator->IsDirectional() ? Ctx.iRotation : 0);

	//	Generate the shape

	CacheShapeRegion(iRotation, iLength, iWidth);

	//	Paint

	DWORD byOpacity = m_pCreator->GetOpacity();
	WORD wColor = m_pCreator->GetColor();

	if (byOpacity == 255)
		m_CachedRegion.Fill(Dest, x, y, wColor);
	else
		m_CachedRegion.FillTrans(Dest, x, y, wColor, byOpacity);
	}
Example #2
0
void CFlarePainter::Paint (CG16bitImage &Dest, int x, int y, SViewportPaintCtx &Ctx)

//	Paint
//
//	Paint

	{
	int i;
	COLORREF wPrimaryColor = m_pCreator->GetPrimaryColor();

	switch (m_pCreator->GetStyle())
		{
		case CFlareEffectCreator::styleFadingBlast:
			{
			//	Radius shrinks proportionally each tick

			int iRadius;
			if (m_iTick < m_pCreator->GetLifetime())
				iRadius = (int)(m_pCreator->GetRadius() * ((Metric)(m_pCreator->GetLifetime() - m_iTick) / (Metric)m_pCreator->GetLifetime()));
			else
				iRadius = 0;

			//	Paint

			if (iRadius)
				{
				//	Paint each of the spikes first

				int iAngle = 360 / MAIN_SPIKE_COUNT;
				for (i = 0; i < MAIN_SPIKE_COUNT; i++)
					{
					SPoint Spike[4];
					m_pCreator->CreateFlareSpike(i * iAngle, iRadius, iRadius / MAIN_SPIKE_WIDTH_RATIO, Spike);

					CG16bitRegion Region;
					Region.CreateFromConvexPolygon(4, Spike);
					Region.FillTrans(Dest, x, y, wPrimaryColor, 128);
					}

				//	Paint central glow

#if 0
				DrawAlphaGradientCircle(Dest,
						x,
						y,
						iRadius / 8,
						wPrimaryColor);
#endif

				//	Paint the extended glow

				DrawAlphaGradientCircle(Dest,
						x,
						y,
						iRadius,
						wPrimaryColor);
				}

			break;
			}
		}
	}
Example #3
0
void CBeamEffectCreator::DrawBeamLightningBolt (CG16bitImage &Dest, SLineDesc &Line, SViewportPaintCtx &Ctx)

//	DrawBeamLightningBolt
//
//	Draws the appropriate beam

	{
	int i;

	//	Compute a set of points for the lightning

	int iPointCount = LIGHTNING_POINT_COUNT;
	CVector *pPoints = new CVector [iPointCount];
	pPoints[0] = CVector(Line.xFrom, Line.yFrom);
	pPoints[iPointCount - 1] = CVector(Line.xTo, Line.yTo);

	ComputeLightningPoints(iPointCount, pPoints, 0.3);

	//	Draw based on intensity

	switch (m_iIntensity)
		{
		//	Draw nothing

		case 0:
			break;

		//	At intensity 1 or 2 just draw a lightning line with the primary color

		case 1:
		case 2:
			{
			for (i = 0; i < iPointCount-1; i++)
				{
				const CVector &vFrom = pPoints[i];
				const CVector &vTo = pPoints[i + 1];

				Dest.DrawLine((int)vFrom.GetX(), (int)vFrom.GetY(),
						(int)vTo.GetX(), (int)vTo.GetY(),
						m_iIntensity,
						m_wPrimaryColor);
				}
			break;
			}

		//	At intensity 3 or 4 draw secondary color around primary.

		case 3:
		case 4:
			{
			for (i = 0; i < iPointCount-1; i++)
				{
				const CVector &vFrom = pPoints[i];
				const CVector &vTo = pPoints[i + 1];

				Dest.DrawLine((int)vFrom.GetX(), (int)vFrom.GetY(),
						(int)vTo.GetX(), (int)vTo.GetY(),
						m_iIntensity,
						m_wSecondaryColor);
				}

			for (i = 0; i < iPointCount-1; i++)
				{
				const CVector &vFrom = pPoints[i];
				const CVector &vTo = pPoints[i + 1];

				Dest.DrawLine((int)vFrom.GetX(), (int)vFrom.GetY(),
						(int)vTo.GetX(), (int)vTo.GetY(),
						m_iIntensity - 2,
						m_wPrimaryColor);
				}
			break;
			}

		//	At intensity 5-10 we draw a glow around the beam

		case 5:
		case 6:
		case 7:
		case 8:
		case 9:
		case 10:
			{
			//	Create a polygon for the glow shaped like a wide version of the
			//	lightning bolt.

			CG16bitRegion GlowRegion;
			CreateLightningGlow(Line, iPointCount, pPoints, m_iIntensity, &GlowRegion);

			//	Paint the glow

			GlowRegion.FillTrans(Dest, 0, 0, m_wSecondaryColor, 128);

			//	Paint the main bolt

			for (i = 0; i < iPointCount-1; i++)
				{
				const CVector &vFrom = pPoints[i];
				const CVector &vTo = pPoints[i + 1];

				Dest.DrawLine((int)vFrom.GetX(), (int)vFrom.GetY(),
						(int)vTo.GetX(), (int)vTo.GetY(),
						4,
						m_wSecondaryColor);
				}

			for (i = 0; i < iPointCount-1; i++)
				{
				const CVector &vFrom = pPoints[i];
				const CVector &vTo = pPoints[i + 1];

				Dest.DrawLine((int)vFrom.GetX(), (int)vFrom.GetY(),
						(int)vTo.GetX(), (int)vTo.GetY(),
						2,
						m_wPrimaryColor);
				}

			break;
			}

		//	For even larger beams we do a double glow

		default:
			{
			//	Create a polygon for the glow shaped like a wide version of the
			//	lightning bolt.

			CG16bitRegion GlowRegion1;
			CreateLightningGlow(Line, iPointCount, pPoints, m_iIntensity, &GlowRegion1);

			CG16bitRegion GlowRegion2;
			CreateLightningGlow(Line, iPointCount, pPoints, 10, &GlowRegion2);

			//	Paint the glow

			GlowRegion1.FillTrans(Dest, 0, 0, m_wSecondaryColor, 48);
			GlowRegion2.FillTrans(Dest, 0, 0, m_wSecondaryColor, 96);

			//	Paint the main bolt

			for (i = 0; i < iPointCount-1; i++)
				{
				const CVector &vFrom = pPoints[i];
				const CVector &vTo = pPoints[i + 1];

				Dest.DrawLine((int)vFrom.GetX(), (int)vFrom.GetY(),
						(int)vTo.GetX(), (int)vTo.GetY(),
						4,
						m_wSecondaryColor);
				}

			for (i = 0; i < iPointCount-1; i++)
				{
				const CVector &vFrom = pPoints[i];
				const CVector &vTo = pPoints[i + 1];

				Dest.DrawLine((int)vFrom.GetX(), (int)vFrom.GetY(),
						(int)vTo.GetX(), (int)vTo.GetY(),
						2,
						m_wPrimaryColor);
				}

			break;
			}
		}

	//	Done

	delete [] pPoints;
	}
Example #4
0
void CFlarePainter::Paint (CG16bitImage &Dest, int x, int y, SViewportPaintCtx &Ctx)

//	Paint
//
//	Paint

	{
	int i;
	
	//	Safety checks

	int iTotalLifetime = m_pCreator->GetLifetime();
	if (iTotalLifetime <= 0)
		return;

	switch (m_pCreator->GetStyle())
		{
		case CFlareEffectCreator::styleFadingBlast:
			{

			//	Radius shrinks proportionally each tick

			int iRadius;
			if (m_iTick < m_pCreator->GetLifetime())
				iRadius = (int)(m_pCreator->GetRadius() * ((Metric)(m_pCreator->GetLifetime() - m_iTick) / (Metric)iTotalLifetime));
			else
				iRadius = 0;

			//	Color moves from primary to secondary

			WORD wColor;
			if (m_pCreator->GetPrimaryColor() != m_pCreator->GetSecondaryColor())
				wColor = CG16bitImage::FadeColor(m_pCreator->GetPrimaryColor(), m_pCreator->GetSecondaryColor(), 100 * m_iTick / iTotalLifetime);
			else
				wColor = m_pCreator->GetPrimaryColor();

			//	Paint

			if (iRadius)
				{
				//	Paint each of the spikes first

				int iAngle = 360 / MAIN_SPIKE_COUNT;
				for (i = 0; i < MAIN_SPIKE_COUNT; i++)
					{
					SPoint Spike[4];
					m_pCreator->CreateFlareSpike(i * iAngle, iRadius, iRadius / MAIN_SPIKE_WIDTH_RATIO, Spike);

					CG16bitRegion Region;
					Region.CreateFromSimplePolygon(4, Spike);
					Region.FillTrans(Dest, x, y, wColor, MAIN_SPIKE_OPACITY);
					}

				//	Paint the extended glow

				DrawAlphaGradientCircle(Dest,
						x,
						y,
						iRadius,
						wColor);
				}

			break;
			}
		}
	}