Exemplo n.º 1
0
void CFlarePainter::PaintFlare (CG32bitImage &Dest, int x, int y, int iRadius, CG32bitPixel rgbColor, bool bSpikes, SViewportPaintCtx &Ctx)

//	PaintFlare
//
//	Paints a flare

{
    int i;

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

        if (bSpikes)
        {
            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);

                CG16bitBinaryRegion Region;
                Region.CreateFromSimplePolygon(4, Spike);
                Region.Fill(Dest, x, y, CG32bitPixel(rgbColor, MAIN_SPIKE_OPACITY));
            }
        }

        //	Paint the extended glow

        CGDraw::CircleGradient(Dest, x, y, iRadius, rgbColor);
    }
}
Exemplo n.º 2
0
void CFlarePainter::GetRect (RECT *retRect) const

//	GetRect
//
//	Returns the RECT of the effect centered on 0,0

{
    int iRadius = m_pCreator->GetRadius();

    retRect->left = -iRadius;
    retRect->top = -iRadius;
    retRect->right = iRadius + 1;
    retRect->bottom = iRadius + 1;
}
Exemplo n.º 3
0
void CFlarePainter::Paint (CG32bitImage &Dest, int x, int y, SViewportPaintCtx &Ctx)

//	Paint
//
//	Paint

{
    int iTotalLifetime = m_pCreator->GetLifetime();

    switch (m_pCreator->GetStyle())
    {
    case CFlareEffectCreator::styleFlicker:
        if ((m_iTick % 2) == 0)
            PaintFlare(Dest, x, y, m_pCreator->GetRadius(), m_pCreator->GetPrimaryColor(), true, Ctx);
        break;

    case CFlareEffectCreator::stylePlain:
        PaintFlare(Dest, x, y, m_pCreator->GetRadius(), m_pCreator->GetPrimaryColor(), false, Ctx);
        break;

    case CFlareEffectCreator::styleFadingBlast:
    {
        //	Safety checks

        if (iTotalLifetime <= 0)
            return;

        //	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

        CG32bitPixel rgbColor;
        if (m_pCreator->GetPrimaryColor() != m_pCreator->GetSecondaryColor())
            rgbColor = CG32bitPixel::Fade(m_pCreator->GetPrimaryColor(), m_pCreator->GetSecondaryColor(), 100 * m_iTick / iTotalLifetime);
        else
            rgbColor = m_pCreator->GetPrimaryColor();

        //	Paint

        PaintFlare(Dest, x, y, iRadius, rgbColor, true, Ctx);

        break;
    }
    }
}
Exemplo n.º 4
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;
			}
		}
	}
Exemplo n.º 5
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;
			}
		}
	}