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

//	Paint
//
//	Paint effect

	{
	//	Compute the length of the bolt based on the time

	int iLength = m_iLength + (m_iGrowth * (Min(8, Ctx.iTick)));

	//	Create the outer shape

	SPoint Poly[SHAPE_COUNT];
	CreateBoltShape(Ctx.iRotation, iLength, m_iWidth, Poly);

	//	Paint

	CG16bitRegion Region;
	WORD wColor = CG16bitImage::BlendPixel(Ctx.wSpaceColor, m_wSecondaryColor, 200);
	Region.CreateFromConvexPolygon(SHAPE_COUNT, Poly);
	Region.Fill(Dest, x, y, wColor);

	//	Create the inner shape

	CreateBoltShape(Ctx.iRotation, Max(16, iLength * 7 / 8), Max(2, m_iWidth * 7 / 8), Poly);

	//	Paint

	Region.CreateFromConvexPolygon(SHAPE_COUNT, Poly);
	Region.Fill(Dest, x, y, m_wPrimaryColor);
	}
Beispiel #2
0
void CBeamEffectCreator::DrawBeamHeavyBlaster (CG16bitImage &Dest, SLineDesc &Line, SViewportPaintCtx &Ctx)

//	DrawBeamHeavyBlaster
//
//	Draws the appropriate beam

	{
	//	Convert to an angle relative to xTo, yTo

	CVector vVec(Line.xFrom - Line.xTo, Line.yFrom - Line.yTo);
	Metric rRadius;
	int iAngle = VectorToPolar(vVec, &rRadius);
	int iRadius = (int)rRadius;

	//	Can't deal with 0 sized lines

	if (iRadius == 0)
		return;

	CG16bitRegion Region;
	SPoint Poly[8];

	//	Compute some metrics

	int iLengthUnit = iRadius * (10 + m_iIntensity) / 40;
	int iWidthUnit = Max(1, iRadius * m_iIntensity / 60);

	//	Paint the outer-most glow

	WORD wColor = CG16bitImage::BlendPixel(Ctx.wSpaceColor, m_wSecondaryColor, 100);
	CreateBlasterShape(iAngle, 4 * iLengthUnit, 3 * iWidthUnit / 2, Poly);
	Region.CreateFromConvexPolygon(8, Poly);
	Region.Fill(Dest, Line.xTo, Line.yTo, wColor);

	//	Paint the inner transition

	wColor = CG16bitImage::BlendPixel(m_wSecondaryColor, m_wPrimaryColor, 128);
	wColor = CG16bitImage::BlendPixel(Ctx.wSpaceColor, wColor, 200);
	CreateBlasterShape(iAngle, 3 * iLengthUnit, iWidthUnit, Poly);
	Region.CreateFromConvexPolygon(8, Poly);
	Region.Fill(Dest, Line.xTo, Line.yTo, wColor);

	//	Paint the inner core

	CreateBlasterShape(iAngle, iLengthUnit, iWidthUnit - 1, Poly);
	Region.CreateFromConvexPolygon(8, Poly);
	Region.Fill(Dest, Line.xTo, Line.yTo, m_wPrimaryColor);
	}
Beispiel #3
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);
	}
Beispiel #4
0
void CBeamEffectCreator::DrawBeamLightning (CG16bitImage &Dest, SLineDesc &Line, SViewportPaintCtx &Ctx)

//	DrawBeamLightning
//
//	Draws the appropriate beam

	{
	//	The central part of the beam is different depending on the
	//	intensity.

	if (m_iIntensity < 4)
		{
		WORD wStart = CG16bitImage::BlendPixel(Ctx.wSpaceColor, m_wPrimaryColor, 128);
		Dest.DrawBiColorLine(Line.xFrom, Line.yFrom,
				Line.xTo, Line.yTo,
				3,
				Ctx.wSpaceColor,
				wStart);

		WORD wEnd = CG16bitImage::BlendPixel(Ctx.wSpaceColor, m_wPrimaryColor, 155);
		Dest.DrawBiColorLine(Line.xFrom, Line.yFrom,
				Line.xTo, Line.yTo,
				1,
				wEnd,
				m_wPrimaryColor);
		}
	else if (m_iIntensity < 10)
		{
		WORD wStart = CG16bitImage::BlendPixel(Ctx.wSpaceColor, m_wSecondaryColor, 155);
		Dest.DrawBiColorLine(Line.xFrom, Line.yFrom,
				Line.xTo, Line.yTo,
				5,
				Ctx.wSpaceColor,
				wStart);

		Dest.DrawBiColorLine(Line.xFrom, Line.yFrom,
				Line.xTo, Line.yTo,
				3,
				Ctx.wSpaceColor,
				m_wSecondaryColor);

		WORD wEnd = CG16bitImage::BlendPixel(Ctx.wSpaceColor, m_wPrimaryColor, 155);
		Dest.DrawBiColorLine(Line.xFrom, Line.yFrom,
				Line.xTo, Line.yTo,
				1,
				wEnd,
				m_wPrimaryColor);
		}
	else
		{
		//	Convert to an angle relative to xTo, yTo

		CVector vVec(Line.xFrom - Line.xTo, Line.yFrom - Line.yTo);
		Metric rRadius;
		int iAngle = VectorToPolar(vVec, &rRadius);
		int iRadius = (int)rRadius;

		//	Can't deal with 0 sized lines

		if (iRadius == 0)
			return;

		CG16bitRegion Region;
		SPoint Poly[8];

		//	Paint the outer-most glow

		WORD wColor = CG16bitImage::BlendPixel(Ctx.wSpaceColor, m_wSecondaryColor, 100);
		CreateBlasterShape(iAngle, iRadius, iRadius / 6, Poly);
		Region.CreateFromConvexPolygon(8, Poly);
		Region.Fill(Dest, Line.xTo, Line.yTo, wColor);

		//	Paint the inner transition

		wColor = CG16bitImage::BlendPixel(m_wSecondaryColor, m_wPrimaryColor, 128);
		wColor = CG16bitImage::BlendPixel(Ctx.wSpaceColor, wColor, 200);
		CreateBlasterShape(iAngle, iRadius * 2 / 3, iRadius / 7, Poly);
		Region.CreateFromConvexPolygon(8, Poly);
		Region.Fill(Dest, Line.xTo, Line.yTo, wColor);

		//	Paint the inner core

		CreateBlasterShape(iAngle, iRadius / 2, iRadius / 8, Poly);
		Region.CreateFromConvexPolygon(8, Poly);
		Region.Fill(Dest, Line.xTo, Line.yTo, m_wPrimaryColor);
		}

	//	Compute the half-way point

	int xHalf = (Line.xFrom + Line.xTo) / 2;
	int yHalf = (Line.yFrom + Line.yTo) / 2;

	//	Draw lightning

	int iCount = m_iIntensity + mathRandom(0, 2);
	for (int j = 0; j < iCount; j++)
		if (mathRandom(1, 2) == 1)
			DrawLightning(Dest, 
					xHalf, 
					yHalf, 
					Line.xTo, 
					Line.yTo, 
					m_wPrimaryColor, 
					LIGHTNING_POINT_COUNT, 
					0.5);
		else
			DrawLightning(Dest, 
					Line.xFrom, 
					Line.yFrom, 
					Line.xTo, 
					Line.yTo, 
					m_wSecondaryColor, 
					LIGHTNING_POINT_COUNT, 
					0.3);
	}