Ejemplo n.º 1
0
void CBoltEffectCreator::Paint (CG32bitImage &Dest, int x, int y, SViewportPaintCtx &Ctx)

//	Paint
//
//	Paint the effect

	{
	//	Paint the tail

	CG32bitPixel rgbStart, rgbEnd;
	int xStart, yStart;
	CVector vTail = PolarToVector(Ctx.iRotation, m_iLength);

	if (m_iWidth >= 3)
		{
		xStart = x - (int)(vTail.GetX() + 0.5);
		yStart = y + (int)(vTail.GetY() + 0.5);

		rgbStart = CG32bitPixel(m_rgbSecondaryColor, 155);
		rgbEnd = CG32bitPixel(m_rgbSecondaryColor, 0);
		CGDraw::LineGradient(Dest, xStart, yStart, x, y, m_iWidth, rgbEnd, rgbStart);
		}

	vTail = vTail / 2.0;
	xStart = x - (int)(vTail.GetX() + 0.5);
	yStart = y + (int)(vTail.GetY() + 0.5);

	rgbStart = m_rgbPrimaryColor;
	rgbEnd = CG32bitPixel(m_rgbSecondaryColor, 200);
	CGDraw::LineGradient(Dest, xStart, yStart, x, y, Max(1, m_iWidth / 2), rgbEnd, rgbStart);
	}
Ejemplo n.º 2
0
CGButtonArea::CGButtonArea (void) : 
		m_rgbLabelColor(CG32bitPixel(255,255,255)),
		m_pLabelFont(NULL),

		m_rgbAccelColor(CG32bitPixel(255,255,0)),
		m_iAccelerator(-1),

		m_rgbDescColor(CG32bitPixel(255,255,255)),
		m_pDescFont(NULL),
		m_cxJustifyWidth(0),

		m_iBorderRadius(0),
		m_rgbBorderColor(CG32bitPixel::Null()),
		m_rgbBackColor(CG32bitPixel::Null()),
		m_rgbBackColorHover(CG32bitPixel::Null()),

		m_bMouseOver(false),
		m_bDisabled(false)

//	CGButtonArea constructor

	{
	m_rcPadding.left = 0;
	m_rcPadding.top = 0;
	m_rcPadding.right = 0;
	m_rcPadding.bottom = 0;
	}
Ejemplo n.º 3
0
CGlowingRingPainter::CGlowingRingPainter (CG32bitImage &Dest, int iRadius, int iWidth, CG32bitPixel rgbColor) :
		m_Dest(Dest),
		m_rcClip(Dest.GetClipRect()),
		m_iRadius(iRadius),
		m_iWidth(iWidth)

//	CGlowingRingPainter constructor

	{
	int i;

	if (m_iWidth <= 0)
		{
		m_pColorRamp = NULL;
		return;
		}

	//	Generate a color ramp

	int iCenter = m_iWidth / 2;
	int iExtra = m_iWidth % 2;
	int iOuter = iCenter - 1;
	int iInner = iCenter + iExtra;

	m_ColorRamp.InsertEmpty(m_iWidth);

	//	We expect the color ramp to be pre-multiplied

	CG32bitPixel rgbPreMult = CG32bitPixel::PreMult(rgbColor);

	//	Init the center

	if (iExtra)
		m_ColorRamp[iCenter] = rgbPreMult;

	//	Edges

	for (i = 0; i < iCenter; i++)
		{
		ASSERT(iOuter >= 0 && iOuter < m_iWidth);
		ASSERT(iInner >=0 && iInner < m_iWidth);

		BYTE byAlpha = (BYTE)Min((WORD)0xff, (WORD)(rgbPreMult.GetAlpha() * (iCenter - i) / (iCenter + 1)));
		BYTE byRed = (BYTE)Min((WORD)0xff, (WORD)(rgbPreMult.GetRed() * (iCenter - i) / (iCenter + 1)));
		BYTE byGreen = (BYTE)Min((WORD)0xff, (WORD)(rgbPreMult.GetGreen() * (iCenter - i) / (iCenter + 1)));
		BYTE byBlue = (BYTE)Min((WORD)0xff, (WORD)(rgbPreMult.GetBlue() * (iCenter - i) / (iCenter + 1)));

		m_ColorRamp[iOuter] = CG32bitPixel(byRed, byGreen, byBlue, byAlpha);
		m_ColorRamp[iInner] = CG32bitPixel(byRed, byGreen, byBlue, byAlpha);

		iOuter--;
		iInner++;
		}

	m_pColorRamp = &m_ColorRamp;
	}
Ejemplo n.º 4
0
void CAniRichText::Paint (SAniPaintCtx &Ctx)

//	Paint
//
//	Paints

	{
	int i;

	//	Get some metrics

	CVector vPos = Ctx.ToDest.Transform(m_Properties[INDEX_POSITION].GetVector());
	int x = (int)vPos.GetX();
	int y = (int)vPos.GetY();

	CVector vSize = m_Properties[INDEX_SCALE].GetVector();

	//	Make sure we are formatted

	Format((int)vSize.GetX(), (int)vSize.GetY());

	//	Paint

	for (i = 0; i < m_Text.GetFormattedSpanCount(); i++)
		{
		const SFormattedTextSpan &Span = m_Text.GetFormattedSpan(i);
		DWORD dwOpacity = Span.Format.dwOpacity * Ctx.dwOpacityToDest / 255;

		Span.Format.pFont->DrawText(Ctx.Dest,
				x + Span.x,
				y + Span.y,
				CG32bitPixel(Span.Format.rgbColor, (BYTE)dwOpacity),
				Span.sText);
		}
	}
Ejemplo n.º 5
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);
    }
}
Ejemplo n.º 6
0
void CGTextArea::Paint (CG32bitImage &Dest, const RECT &rcRect)

//	Paint
//
//	Handle paint

	{
	RECT rcText = CalcTextRect(rcRect);

	//	Paint the background

	if (m_iBorderRadius > 0)
		CGDraw::RoundedRect(Dest, rcRect.left, rcRect.top, RectWidth(rcRect), RectHeight(rcRect), m_iBorderRadius, m_rgbBackColor);
	else
		Dest.Fill(rcRect.left, rcRect.top, RectWidth(rcRect), RectHeight(rcRect), m_rgbBackColor);

	//	Paint the editable box

	if (m_bEditable)
		{
		CG32bitPixel rgbBorderColor = CG32bitPixel::Blend(CG32bitPixel(0, 0, 0), m_rgbColor, (BYTE)128);
		CGDraw::RectOutlineDotted(Dest, rcRect.left, rcRect.top, RectWidth(rcRect), RectHeight(rcRect), rgbBorderColor);
		}

	//	Paint the content

	if (!m_sText.IsBlank())
		PaintText(Dest, rcText);
	else
		PaintRTF(Dest, rcText);
	}
Ejemplo n.º 7
0
CGlowingRingPainter::CGlowingRingPainter (CG32bitImage &Dest, int iRadius, int iWidth, const TArray<CG32bitPixel> &ColorRamp, BYTE byOpacity) :
		m_Dest(Dest),
		m_rcClip(Dest.GetClipRect()),
		m_iRadius(iRadius),
		m_iWidth(iWidth)

//	CGlowingRingPainter constructor

	{
	int i;

	//	Pre-multiply the color ramp

	m_ColorRamp.InsertEmpty(ColorRamp.GetCount());
	m_pColorRamp = &m_ColorRamp;

	if (byOpacity == 0xff)
		{
		for (i = 0; i < m_ColorRamp.GetCount(); i++)
			m_ColorRamp[i] = CG32bitPixel::PreMult(ColorRamp[i]);
		}
	else
		{
		for (i = 0; i < m_ColorRamp.GetCount(); i++)
			{
			CG32bitPixel rgbPreMult = CG32bitPixel::PreMult(ColorRamp[i]);
			m_ColorRamp[i] = CG32bitPixel(CG32bitPixel::Blend(0, rgbPreMult, byOpacity), CG32bitPixel::BlendAlpha(rgbPreMult.GetAlpha(), byOpacity));
			}
		}
	}
void CArtifactStatPainter::Paint (CG32bitImage &Dest) const

//	Paint
//
//	Paint the stat

	{
	const CG16bitFont &LabelFont = m_VI.GetFont(fontSmall);
	const CG16bitFont &StatFont = m_VI.GetFont(fontLargeBold);

	CG32bitPixel rgbBack = AA_STYLECOLOR(colorCountermeasureLocusBack);
	CG32bitPixel rgbLabel = CG32bitPixel(0x80, 0x80, 0x80);
	CG32bitPixel rgbStat = AA_STYLECOLOR(colorAICoreFore);

	//	Paint the background first

	CGDraw::RoundedRect(Dest,
			m_rcRect.left,
			m_rcRect.top,
			RectWidth(m_rcRect),
			RectHeight(m_rcRect),
			CORNER_RADIUS,
			rgbBack);

	//	Paint the label

	LabelFont.DrawText(Dest, m_rcRect, rgbLabel, m_sLabel, 0, CG16bitFont::AlignCenter);

	//	Paint the stat

	RECT rcRect = m_rcRect;
	rcRect.top += LabelFont.GetHeight();
	StatFont.DrawText(Dest, rcRect, rgbStat, strFromInt(m_iValue), 0, CG16bitFont::AlignCenter);
	}
Ejemplo n.º 9
0
CGImageArea::CGImageArea (void) : m_pImage(NULL),
		m_rgbBackColor(CG32bitPixel(0,0,0)),
		m_bTransBackground(false),
		m_dwStyles(alignLeft | alignTop)

//	CGImageArea constructor

	{
	}
Ejemplo n.º 10
0
void CAniSolidFill::Fill (SAniPaintCtx &Ctx, int x, int y, const CG16bitBinaryRegion &Region)

//	Fill
//
//	Fills the region

	{
	Region.Fill(Ctx.Dest, x, y, CG32bitPixel(m_rgbColor, (BYTE)m_dwOpacity));
	}
Ejemplo n.º 11
0
CG32bitPixel CG32bitPixel::Darken (CG32bitPixel rgbSource, BYTE byOpacity)

//	Darken
//
//	Equivalent to Blend(0, rgbSource, byOpacity)
	
	{
	BYTE *pAlpha = g_Alpha8[byOpacity];
	return CG32bitPixel(pAlpha[rgbSource.GetRed()], pAlpha[rgbSource.GetGreen()], pAlpha[rgbSource.GetBlue()]);
	}
Ejemplo n.º 12
0
void CAniSolidFill::Fill (SAniPaintCtx &Ctx, int x, int y, int cxWidth, int cyHeight)

//	Fill
//
//	Fill

	{
	if (m_dwOpacity == 255)
		Ctx.Dest.Fill(x, y, cxWidth, cyHeight, m_rgbColor);
	else if (m_dwOpacity > 0)
		Ctx.Dest.Fill(x, y, cxWidth, cyHeight, CG32bitPixel(m_rgbColor, (BYTE)m_dwOpacity));
	}
void CAdventureIntroSession::OnPaint (CG32bitImage &Screen, const RECT &rcInvalid)

//	OnPaint
//
//	Paint

	{
	const CVisualPalette &VI = m_HI.GetVisuals();

	RECT rcCenter;
	VI.DrawSessionBackground(Screen, CG32bitImage(), CG32bitPixel(), CVisualPalette::OPTION_SESSION_DLG_BACKGROUND, &rcCenter);
	}
Ejemplo n.º 14
0
void CPolyflashPainter::Paint (CG32bitImage &Dest, int x, int y, SViewportPaintCtx &Ctx)

//	Paint
//
//	Paints the flash

	{
	CG16bitBinaryRegion Region;
	SPoint Poly[6];

	//	Create the broad outer flame

	CreateFlame(Ctx.iRotation, 40, Poly);
	Region.CreateFromConvexPolygon(6, Poly);
	Region.Fill(Dest, x, y, CG32bitPixel(0xff, 0x80, 0x40, 0x80));

	//	Create the central bright area

	CreateFlame(Ctx.iRotation, 30, Poly);
	Region.CreateFromConvexPolygon(6, Poly);
	Region.Fill(Dest, x, y, CG32bitPixel(0xff, 0xff, 0xa0));
	}
Ejemplo n.º 15
0
CG32bitPixel CG32bitPixel::PreMult (CG32bitPixel rgbColor, BYTE byAlpha)

//	PreMult
//
//	Returns a new color premultiplied by the alpha value.

	{
	if (byAlpha == 0x00)
		return CG32bitPixel::Null();
	else if (byAlpha == 0xff)
		return CG32bitPixel(rgbColor, 0xff);
	else
		{
		BYTE *pAlpha = CG32bitPixel::AlphaTable(byAlpha);

		BYTE byRed = rgbColor.GetRed();
		BYTE byGreen = rgbColor.GetGreen();
		BYTE byBlue = rgbColor.GetBlue();

		return CG32bitPixel(pAlpha[byRed], pAlpha[byGreen], pAlpha[byBlue], byAlpha);
		}
	}
Ejemplo n.º 16
0
void CBeam::OnPaint (CG32bitImage &Dest, int x, int y, SViewportPaintCtx &Ctx)

//	OnPaint
//
//	Paint the beam

{
    //	Setup structure

    SBeamDrawCtx BeamCtx;
    BeamCtx.xFrom = x + m_xFromOffset;
    BeamCtx.yFrom = y + m_yFromOffset;
    if (m_pHit)
        Ctx.XForm.Transform(m_vPaintTo, &BeamCtx.xTo, &BeamCtx.yTo);
    else
    {
        BeamCtx.xTo = x + m_xToOffset;
        BeamCtx.yTo = y + m_yToOffset;
    }
    BeamCtx.iIntensity = 1;
    BeamCtx.rgbBackgroundColor = CG32bitPixel::Null();
    BeamCtx.rgbPrimaryColor = CG32bitPixel(0xf1, 0x5f, 0x2a);
    BeamCtx.rgbSecondaryColor = CG32bitPixel(0xff, 0x00, 0x00);

    //	Paint a line

    DrawLaserBeam(Dest, BeamCtx);

    //	Draw the head of the beam if we have an image

    if (m_pDesc->m_Image.IsLoaded())
    {
        m_pDesc->m_Image.PaintImage(Dest,
                                    BeamCtx.xTo,
                                    BeamCtx.yTo,
                                    m_iTick,
                                    0);
    }
}
Ejemplo n.º 17
0
void CTransmuterSession::OnPaint(CG32bitImage &Screen, const RECT &rcInvalid)
	{
	//	paint the background
	Screen.Fill(0, 0, Screen.GetWidth(), Screen.GetHeight(), CG32bitPixel(32, 32, 32));

	//	make sure m_SubSessions is up-to-date with any error sessions
	UpdateSubSessionsList();

	//	call paint functions of all subsessions
	for (int i = 0; i < m_SubSessions.GetCount(); i++)
		{
		m_SubSessions[i]->OnPaint(Screen, rcInvalid);
		}
	}
Ejemplo n.º 18
0
void CGImageArea::Paint (CG32bitImage &Dest, const RECT &rcRect)

//	Paint
//
//	Handle paint

	{
	if (!m_bTransBackground)
		Dest.Fill(rcRect.left,
				rcRect.top,
				RectWidth(rcRect),
				RectHeight(rcRect),
				m_rgbBackColor);

	if (m_pImage)
		{
		int x, y;

		//	Compute position of image in the area rect

		if (m_dwStyles & alignCenter)
			x = rcRect.left + (RectWidth(rcRect) - RectWidth(m_rcImage)) / 2;
		else if (m_dwStyles & alignRight)
			x = rcRect.left + (RectWidth(rcRect) - RectWidth(m_rcImage));
		else
			x = rcRect.left;

		if (m_dwStyles & alignMiddle)
			y = rcRect.top + (RectHeight(rcRect) - RectHeight(m_rcImage)) / 2;
		else if (m_dwStyles & alignBottom)
			y = rcRect.top + (RectHeight(rcRect) - RectHeight(m_rcImage));
		else
			y = rcRect.top;

		//	Blt
		//
		//	For compatibility with previous (Transcendence) releases, we assume
		//	black is transparent if the image has no alpha channel.

		CGDraw::BltWithBackColor(Dest,
				x,
				y,
				*m_pImage,
				m_rcImage.left,
				m_rcImage.top,
				RectWidth(m_rcImage),
				RectHeight(m_rcImage),
				CG32bitPixel(0, 0, 0));
		}
	}
Ejemplo n.º 19
0
CAniTextInput::CAniTextInput (void) :
		m_bFocus(false),
		m_bPassword(false)

//	CAniTextInput constructor

	{
	m_Properties.SetInteger(PROP_VISIBLE, 1);
	m_Properties.SetVector(PROP_POSITION, CVector());
	m_Properties.SetVector(PROP_SCALE, CVector(1.0, 1.0));
	m_Properties.SetInteger(PROP_ROTATION, 0);
	m_Properties.SetColor(PROP_COLOR, 0xffff);
	m_Properties.SetOpacity(PROP_OPACITY, 255);
	m_Properties.SetString(PROP_TEXT, NULL_STR);
	m_Properties.SetColor(PROP_FOCUS_BORDER_COLOR, 0xffff);
	m_Properties.SetBool(PROP_ENABLED, true);
	m_Properties.SetFont(PROP_FONT, NULL);
	m_Properties.SetFont(PROP_LABEL_FONT, NULL);
	m_Properties.SetString(PROP_LABEL_TEXT, NULL_STR);
	m_Properties.SetColor(PROP_LABEL_COLOR, 0xffff);

	IAnimatron *pStyle = new CAniRect;
	pStyle->SetPropertyColor(PROP_COLOR, CG32bitPixel(64, 64, 64));
	pStyle->SetPropertyOpacity(PROP_OPACITY, 255);
	SetStyle(styleFrame, pStyle);

	pStyle = new CAniRect;
	pStyle->SetPropertyColor(PROP_COLOR, CG32bitPixel(128, 128, 128));
	pStyle->SetPropertyOpacity(PROP_OPACITY, 255);
	SetStyle(styleFrameFocus, pStyle);

	pStyle = new CAniRect;
	pStyle->SetPropertyColor(PROP_COLOR, CG32bitPixel(64, 64, 64));
	pStyle->SetPropertyOpacity(PROP_OPACITY, 128);
	SetStyle(styleFrameDisabled, pStyle);
	}
Ejemplo n.º 20
0
void CShockwaveEffectCreator::CreateGlowGradient (int iSolidWidth, int iGlowWidth, CG32bitPixel rgbSolidColor, CG32bitPixel rgbGlowColor)

//	CreateGlowGradient
//
//	Creates a gradient for a glowing ring

	{
	int i;

	ASSERT(iSolidWidth >= 0);
	ASSERT(iGlowWidth >= 0);
	ASSERT(iSolidWidth + iGlowWidth > 0);

	m_iGradientCount = iSolidWidth + 2 * iGlowWidth;
	m_ColorGradient.DeleteAll();
	if (m_iGradientCount <= 0)
		return;

	m_ColorGradient.InsertEmpty(m_iGradientCount);

	//	Add glow ramp

	for (i = 0; i < iGlowWidth; i++)
		{
		int iFade = (256 * (i + 1) / (iGlowWidth + 1));

		CG32bitPixel rgbColor = CG32bitPixel::Blend(rgbGlowColor, rgbSolidColor, (BYTE)iFade);
		m_ColorGradient[i] = CG32bitPixel(rgbColor, (BYTE)iFade);
		m_ColorGradient[m_iGradientCount - (i + 1)] = CG32bitPixel(rgbColor, (BYTE)iFade);
		}

	//	Add the solid color in the center

	for (i = 0; i < iSolidWidth; i++)
		m_ColorGradient[iGlowWidth + i] = rgbSolidColor;
	}
Ejemplo n.º 21
0
CG32bitImage *CSystemMap::CreateBackgroundImage (void)

//	CreateBackgroundImage
//
//	Creates an image containing the map.
//	Caller is responsible for freeing the returned image.

	{
	int i;

	CG32bitImage *pImage = g_pUniverse->GetLibraryBitmapCopy(m_dwBackgroundImage);
	if (pImage == NULL)
		return NULL;

	int xCenter = pImage->GetWidth() / 2;
	int yCenter = pImage->GetHeight() / 2;

	//	Paint all annotations

	if (m_Annotations.GetCount() > 0)
		{
		SViewportPaintCtx Ctx;

		for (i = 0; i < m_Annotations.GetCount(); i++)
			{
			SMapAnnotation *pAnnotation = &m_Annotations[i];

			Ctx.iTick = pAnnotation->iTick;
			Ctx.iRotation = pAnnotation->iRotation;

			pAnnotation->pPainter->Paint(*pImage, xCenter + pAnnotation->xOffset, yCenter - pAnnotation->yOffset, Ctx);
			}
		}

#ifdef DEBUG
#if 0
	//	Test noise function
	CG32bitImage Alpha;
	Alpha.CreateBlankAlpha(pImage->GetWidth(), pImage->GetHeight());
	DrawNebulosity8bit(Alpha, 0, 0, pImage->GetWidth(), pImage->GetHeight(), 256, 0, 255);

	pImage->Fill(0, 0, pImage->GetWidth(), pImage->GetHeight(), 0);
	pImage->FillMask(0, 0, pImage->GetWidth(), pImage->GetHeight(), Alpha, CG32bitPixel(255, 255, 255), 0, 0);
#endif
#endif

	return pImage;
	}
Ejemplo n.º 22
0
CG32bitPixel CG32bitPixel::Blend (CG32bitPixel rgbDest, CG32bitPixel rgbSrc, BYTE bySrcAlpha)

//	Blend
//
//	Combines rgbSrc with rgbDest, using bySrcAlpha as the source opacity.
//	We assume source and dest have no alpha component.

	{
	BYTE *pAlpha = g_Alpha8[bySrcAlpha];
	BYTE *pAlphaInv = g_Alpha8[255 - bySrcAlpha];

	BYTE byRedResult = pAlphaInv[rgbDest.GetRed()] + pAlpha[rgbSrc.GetRed()];
	BYTE byGreenResult = pAlphaInv[rgbDest.GetGreen()] + pAlpha[rgbSrc.GetGreen()];
	BYTE byBlueResult = pAlphaInv[rgbDest.GetBlue()] + pAlpha[rgbSrc.GetBlue()];

	return CG32bitPixel(byRedResult, byGreenResult, byBlueResult);
	}
Ejemplo n.º 23
0
CG32bitPixel CG32bitPixel::Blend (CG32bitPixel rgbDest, CG32bitPixel rgbSrc)

//	Blend
//
//	Combines rgbSrc with rgbDest, using rgbSrc as the source opacity.
//	We assume dest has no alpha component and we assume that rgbSrc does.

	{
	BYTE *pAlpha = g_Alpha8[rgbSrc.GetAlpha()];
	BYTE *pAlphaInv = g_Alpha8[rgbSrc.GetAlpha() ^ 0xff];	//	Equivalent to 255 - rgbSrc.GetAlpha()

	BYTE byRedResult = pAlphaInv[rgbDest.GetRed()] + pAlpha[rgbSrc.GetRed()];
	BYTE byGreenResult = pAlphaInv[rgbDest.GetGreen()] + pAlpha[rgbSrc.GetGreen()];
	BYTE byBlueResult = pAlphaInv[rgbDest.GetBlue()] + pAlpha[rgbSrc.GetBlue()];

	return CG32bitPixel(byRedResult, byGreenResult, byBlueResult);
	}
Ejemplo n.º 24
0
void CAniSolidFill::Fill (SAniPaintCtx &Ctx, int x, int y, const TArray<SSimpleRasterLine> &Lines)

//	Fill
//
//	Files the set of lines

	{
	SSimpleRasterLine *pLine = &Lines[0];
	SSimpleRasterLine *pLineEnd = pLine + Lines.GetCount();

	if (m_dwOpacity == 255)
		{
		while (pLine < pLineEnd)
			{
			Ctx.Dest.FillLine(x + pLine->x, y + pLine->y, pLine->cxLength, m_rgbColor);
			if (pLine->byLeftEdge)
				Ctx.Dest.SetPixelTrans(x + pLine->x - 1, y + pLine->y, m_rgbColor, pLine->byLeftEdge);
			if (pLine->byRightEdge)
				Ctx.Dest.SetPixelTrans(x + pLine->x + pLine->cxLength, y + pLine->y, m_rgbColor, pLine->byRightEdge);

			pLine++;
			}
		}
	else if (m_dwOpacity > 0)
		{
		while (pLine < pLineEnd)
			{
			Ctx.Dest.FillLine(x + pLine->x, y + pLine->y, pLine->cxLength, CG32bitPixel(m_rgbColor, (BYTE)m_dwOpacity));

			if (pLine->byLeftEdge)
				{
				DWORD dwOpacity = m_dwOpacity * pLine->byLeftEdge / 255;
				Ctx.Dest.SetPixelTrans(x + pLine->x - 1, y + pLine->y, m_rgbColor, (BYTE)dwOpacity);
				}

			if (pLine->byRightEdge)
				{
				DWORD dwOpacity = m_dwOpacity * pLine->byRightEdge / 255;
				Ctx.Dest.SetPixelTrans(x + pLine->x + pLine->cxLength, y + pLine->y, m_rgbColor, (BYTE)dwOpacity);
				}

			pLine++;
			}
		}
	}
Ejemplo n.º 25
0
void DrawLaserBeam (CG32bitImage &Dest, const SBeamDrawCtx &Ctx)

//	DrawLaserBeam
//
//	Draws a simple laser beam

{
    CG32bitPixel rgbGlow = CG32bitPixel(Ctx.rgbSecondaryColor, 100);

    Dest.DrawLine(Ctx.xFrom, Ctx.yFrom,
                  Ctx.xTo, Ctx.yTo,
                  3,
                  rgbGlow);

    Dest.DrawLine(Ctx.xFrom, Ctx.yFrom,
                  Ctx.xTo, Ctx.yTo,
                  1,
                  Ctx.rgbPrimaryColor);
}
Ejemplo n.º 26
0
void DrawNode (STopologyMapCtx &Ctx, COutputChart &Output, CTopologyNode *pNode, int x, int y)

//	DrawNode
//
//	Draws a topology node

	{
	CG32bitImage &Dest = Output.GetOutputImage();
	const CG16bitFont &NameFont = Output.GetStyleFont(STYLE_NAME);
	CG32bitPixel rgbNameColor = Output.GetStyleColor(STYLE_NAME);

	CGDraw::CircleGradient(Dest, x + 2, y + 2, NODE_RADIUS + 1, 0);
	CGDraw::Circle(Dest, x, y, NODE_RADIUS, NODE_COLOR);
	CGDraw::CircleGradient(Dest, x - 2, y - 2, NODE_RADIUS, CG32bitPixel(0xff, 0xff, 0xff));

	NameFont.DrawText(Dest,
			x, y + NODE_RADIUS + 2,
			rgbNameColor,
			pNode->GetSystemName(),
			CG16bitFont::AlignCenter);
	}
Ejemplo n.º 27
0
CGTextArea::CGTextArea (void) : 
		m_bEditable(false),
		m_dwStyles(alignLeft),
		m_cyLineSpacing(0),
		m_iBorderRadius(0),
		m_pFont(NULL),
		m_rgbColor(CG32bitPixel(255,255,255)),
		m_rgbBackColor(CG32bitPixel::Null()),
		m_bRTFInvalid(true),
		m_pFontTable(NULL),
		m_cxJustifyWidth(0),
		m_iTick(0),
		m_iCursorLine(-1),
		m_iCursorPos(0)

//	CGTextArea constructor

	{
	m_rcPadding.left = 0;
	m_rcPadding.top = 0;
	m_rcPadding.right = 0;
	m_rcPadding.bottom = 0;
	}
Ejemplo n.º 28
0
CG32bitPixel CG32bitPixel::Blend (CG32bitPixel rgbFrom, CG32bitPixel rgbTo, double rFade)

//	Fade
//
//	Fade from one value to the other. rFade goes from 0 to 1.

	{
	if (rFade <= 0.0)
		return rgbFrom;
	else if (rFade >= 1.0)
		return rgbTo;
	else
		{
		int iRDiff = (int)(DWORD)rgbTo.GetRed() - (int)(DWORD)rgbFrom.GetRed();
		int iGDiff = (int)(DWORD)rgbTo.GetGreen() - (int)(DWORD)rgbFrom.GetGreen();
		int iBDiff = (int)(DWORD)rgbTo.GetBlue() - (int)(DWORD)rgbFrom.GetBlue();

		BYTE byRed = (BYTE)((int)(DWORD)rgbFrom.GetRed() + (iRDiff * rFade));
		BYTE byGreen = (BYTE)((int)(DWORD)rgbFrom.GetGreen() + (iGDiff * rFade));
		BYTE byBlue = (BYTE)((int)(DWORD)rgbFrom.GetBlue() + (iBDiff * rFade));

		return CG32bitPixel(byRed, byGreen, byBlue);
		}
	}
Ejemplo n.º 29
0
CG32bitPixel CG32bitPixel::Fade (CG32bitPixel rgbFrom, CG32bitPixel rgbTo, int iPercent)

//	Fade
//
//	Fade from one value to the other by percent.

	{
	if (iPercent <= 0)
		return rgbFrom;
	else if (iPercent >= 100)
		return rgbTo;
	else
		{
		int iRDiff = (int)(DWORD)rgbTo.GetRed() - (int)(DWORD)rgbFrom.GetRed();
		int iGDiff = (int)(DWORD)rgbTo.GetGreen() - (int)(DWORD)rgbFrom.GetGreen();
		int iBDiff = (int)(DWORD)rgbTo.GetBlue() - (int)(DWORD)rgbFrom.GetBlue();

		BYTE byRed = (BYTE)((int)(DWORD)rgbFrom.GetRed() + (iRDiff * iPercent / 100));
		BYTE byGreen = (BYTE)((int)(DWORD)rgbFrom.GetGreen() + (iGDiff * iPercent / 100));
		BYTE byBlue = (BYTE)((int)(DWORD)rgbFrom.GetBlue() + (iBDiff * iPercent / 100));

		return CG32bitPixel(byRed, byGreen, byBlue);
		}
	}
Ejemplo n.º 30
0
void GenerateTopologyMap (CUniverse &Universe, CXMLElement *pCmdLine)
	{
	int i, j;

	STopologyMapCtx Ctx;

	//	Initialize the output

	COutputChart Output;
	Output.SetStyleFont(STYLE_NAME, pCmdLine->GetAttribute(CONSTLIT("font")));
	Output.SetStyleColor(STYLE_NAME, CG32bitPixel(0xFF, 0xFF, 0xFF));

	Output.SetOutputFilespec(pCmdLine->GetAttribute(CONSTLIT("output")));

	//	Get the topology node

	CTopologyNode *pFirstNode = Universe.GetFirstTopologyNode();
	if (pFirstNode == NULL)
		{
		printf("ERROR: Unable to find topology node.\n");
		return;
		}

	//	Get the system map for the node

	Ctx.pMap = pFirstNode->GetDisplayPos();
	if (Ctx.pMap == NULL)
		{
		printf("ERROR: No system map for node %s.\n", pFirstNode->GetID().GetASCIIZPointer());
		return;
		}

	//	Create a background image

	CG32bitImage *pImage = Ctx.pMap->CreateBackgroundImage();

	//	Create the output

	Output.SetContentSize((pImage ? pImage->GetWidth() : 1024), (pImage ? pImage->GetHeight() : 1024));
	CG32bitImage &Dest = Output.GetOutputImage();

	//	Blt

	if (pImage)
		Dest.Blt(0, 0, pImage->GetWidth(), pImage->GetHeight(), *pImage, 0, 0);

	//	Done with background image

	delete pImage;
	pImage = NULL;

	//	Compute the size of the map (in pixels)

	Ctx.cxMap = Dest.GetWidth();
	Ctx.cyMap = Dest.GetHeight();
	Ctx.xCenter = Ctx.cxMap / 2;
	Ctx.yCenter = Ctx.cyMap / 2;

	//	Loop over all nodes and clear marks on the ones that we need to draw

	for (i = 0; i < Universe.GetTopologyNodeCount(); i++)
		{
		CTopologyNode *pNode = Universe.GetTopologyNode(i);
			
		int xPos, yPos;
		pNode->SetMarked(pNode->GetDisplayPos(&xPos, &yPos) != Ctx.pMap 
				|| pNode->IsEndGame());
		}

	//	Paint the nodes

	for (i = 0; i < Universe.GetTopologyNodeCount(); i++)
		{
		CTopologyNode *pNode = Universe.GetTopologyNode(i);
		if (!pNode->IsMarked())
			{
			int xPos, yPos;
			pNode->GetDisplayPos(&xPos, &yPos);

			//	Convert to view coordinates

			int x = Ctx.xCenter + xPos;
			int y = Ctx.yCenter - yPos;

			//	Draw gate connections

			for (j = 0; j < pNode->GetStargateCount(); j++)
				{
				CTopologyNode *pDestNode = pNode->GetStargateDest(j);
				if (pDestNode && !pDestNode->IsMarked())
					{
					int xPos, yPos;
					pDestNode->GetDisplayPos(&xPos, &yPos);

					int xDest = Ctx.xCenter + xPos;
					int yDest = Ctx.yCenter - yPos;

					Dest.DrawLine(x, y, xDest, yDest, STARGATE_LINE_WIDTH, STARGATE_LINE_COLOR);
					}
				}

			//	Draw star system

			DrawNode(Ctx, Output, pNode, x, y);

			pNode->SetMarked();
			}
		}

	//	Done

	Output.Output();
	}