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


C++ Graphics::DrawLine方法代码示例

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


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

示例1: if

void
MFCArrangeView::DrawGridGraphics(Graphics &pdc, CRect &cbp)
{
	Metric *dm = (displayMetric?displayMetric:quaLink->QMetric());
//	pdc->SetBkColor(rgb_red);
	Pen	ltGrayPen(AlphaColor(255, rgb_ltGray), 1);
	Pen	mdGrayPen(AlphaColor(255, rgb_mdGray), 1);
	Pen	dkGrayPen(AlphaColor(255, rgb_dkGray), 1);

	long startTick = cbp.left/pixPerNotch;
	long endTick = cbp.right/pixPerNotch;
	short notchInc = 1;
	long notchPx = startTick*pixPerNotch;
	long tickCnt = 0;
	short tickPerNotch = 1;
//	cerr << "start tick" << startTick << ", end " << endTick << endl;

	MFCChannelView *fv =(MFCChannelView *)channeler->CR(0);
	MFCChannelView *ev =(MFCChannelView *)channeler->CR(channeler->NCR()-1);
	
	for (tickCnt=startTick; tickCnt<=endTick; tickCnt+=tickPerNotch, notchPx += pixPerNotch) {
		if (tickCnt % (dm->granularity*dm->beatsPerBar) == 0) {
			pdc.DrawLine(&dkGrayPen, notchPx, cbp.top, notchPx, cbp.bottom);
		} else if (tickCnt % dm->granularity == 0) {
			pdc.DrawLine(&mdGrayPen, notchPx, cbp.top, notchPx, cbp.bottom);
		} else {
//			pdc.DrawLine(&ltGrayPen, notchPx, cbp.top, notchPx, cbp.bottom);
		}

	}

	for (short i=0; i<quaLink->NChannel(); i++) {
		pdc.DrawLine(&dkGrayPen, cbp.left, Channel2Pix(i), cbp.right, Channel2Pix(i));
	}
}
开发者ID:dakyri,项目名称:qua,代码行数:35,代码来源:MFCArrangeView.cpp

示例2: if

void
MFCSequenceEditor::DrawGridGraphics(Graphics &pdc, CRect &cbp)
{
	Metric *dm = (displayMetric?displayMetric:NULL);
//	pdc->SetBkColor(rgb_red);
	Pen	ltGrayPen(Color(255, 200, 200, 200), 1);
	Pen	mdGrayPen(Color(255, 140, 140, 140), 1);
	Pen	dkGrayPen(Color(255, 80, 80, 80), 1);

	long startTick = cbp.left/pixPerNotch;
	long endTick = cbp.right/pixPerNotch;
	short notchInc = 1;
	long notchPx = startTick*pixPerNotch;
	long tickCnt = 0;
	short tickPerNotch = 1;

//	MFCChannelView *fv =(MFCChannelView *)channeler->CR(0);
//	MFCChannelView *ev =(MFCChannelView *)channeler->CR(channeler->NCR()-1);

	for (tickCnt=startTick; tickCnt<=endTick; tickCnt+=tickPerNotch, notchPx += pixPerNotch) {
		Pen		*gridPen;
		if (tickCnt % (dm->granularity*dm->beatsPerBar) == 0) {
			gridPen = &dkGrayPen;
		} else if (tickCnt % dm->granularity == 0) {
			gridPen = &mdGrayPen;
		} else {
			gridPen = &ltGrayPen;
		}
		pdc.DrawLine(gridPen, notchPx, cbp.top, notchPx, cbp.bottom);
	}
	for (short i=0; i<NHorizontalPix(); i++) {
		pdc.DrawLine(&dkGrayPen, cbp.left, HorizontalPix(i), cbp.right, HorizontalPix(i));
	}
}
开发者ID:dakyri,项目名称:qua,代码行数:34,代码来源:MFCDataEditor.cpp

示例3: DrawRect

BOOL GDIPluseExt::DrawRect(Graphics &gp,CRect rect,Color linecolor,REAL nbold)
{
	Pen solipen(linecolor,nbold);
	gp.DrawLine(&solipen,Point(rect.left,rect.top),Point(rect.left,rect.bottom));                    //纵向左轴
	gp.DrawLine(&solipen,Point(rect.left,rect.top),Point(rect.right ,rect.top));                       //水平上端轴
	gp.DrawLine(&solipen,Point(rect.right,rect.top),Point(rect.right ,rect.bottom));               //纵向右轴
	gp.DrawLine(&solipen,Point(rect.left,rect.bottom),Point(rect.right,rect.bottom));            //水平下轴
	return TRUE;
}
开发者ID:awendemo,项目名称:Ghca-RasHook,代码行数:9,代码来源:GDIPluseEx.cpp

示例4: DrawBevel

/*
** Draws a bevel inside the given area
*/
void Meter::DrawBevel(Graphics& graphics, const Rect& rect, const Pen& light, const Pen& dark)
{
    int l = rect.GetLeft();
    int r = rect.GetRight() - 1;
    int t = rect.GetTop();
    int b = rect.GetBottom() - 1;

    graphics.DrawLine(&light, l,     t,     l,     b);
    graphics.DrawLine(&light, l,     t,     r,     t);
    graphics.DrawLine(&light, l + 1, t + 1, l + 1, b - 1);
    graphics.DrawLine(&light, l + 1, t + 1, r - 1, t + 1);
    graphics.DrawLine(&dark,  l,     b,     r,     b);
    graphics.DrawLine(&dark,  r,     t,     r,     b);
    graphics.DrawLine(&dark,  l + 1, b - 1, r - 1, b - 1);
    graphics.DrawLine(&dark,  r - 1, t + 1, r - 1, b - 1);
}
开发者ID:Rivolvan,项目名称:rainmeter,代码行数:19,代码来源:Meter.cpp

示例5: DrawRulerMarks

void CToolRegularRuler::DrawRulerMarks(Graphics& graph)
{
	int nNumber = 0;
	int nbegin = m_rcHot.left + 10;
	int nend = m_rcHot.right - 10;

	CString strNumber;
	Font fontNumber(L"Arial", 10);
	SolidBrush brush(Color::Black);
	StringFormat format;
	format.SetAlignment(StringAlignmentCenter);

	Pen penDraw(Color::Black, 1);
	PointF ptBegin((float)nbegin, m_rcHot.top + 1.0f);
	PointF ptEnd = ptBegin;
	graph.SetTextRenderingHint(TextRenderingHintAntiAlias);

	for(int i = nbegin; i < nend; i+= 10)
	{
		ptEnd.X = (float)i;
		ptBegin.X = (float)i;
		if((i - nbegin) % 100 == 0)
		{
			ptEnd.Y = ptBegin.Y + 30;
			graph.DrawLine(&penDraw, ptBegin, ptEnd);
			nNumber = (i - nbegin) / 100;
			strNumber.Format(_T("%d"), nNumber);
			
			graph.DrawString(strNumber, strNumber.GetLength(), &fontNumber, ptEnd, &format, &brush);
		}
		else if((i - nbegin) % 50 == 0)
		{
			ptEnd.Y = ptBegin.Y + 20;
			graph.DrawLine(&penDraw, ptBegin, ptEnd);
		}
		else
		{
			ptEnd.Y = ptBegin.Y + 10;
			graph.DrawLine(&penDraw, ptBegin, ptEnd);
		}
	}
}
开发者ID:lilingshui,项目名称:code-refrence,代码行数:42,代码来源:CToolRegularRuler.cpp

示例6: draw

void Bullet::draw(Graphics& graphics)
{
	postion = postion + velocity;
	int num = (sizeof(bLines) / sizeof(*bLines));
	graphics.SetColor(RGB(200,100,200));
	for(int count = 0; count < num; count ++){
		Vector2D first = bLines[count] + postion;
		Vector2D second = bLines[(count+1)%num] + postion;
		graphics.DrawLine(first.x, first.y, second.x, second.y);
	}
}
开发者ID:JMichaelWatson,项目名称:JWatsonGameSkeleton,代码行数:11,代码来源:Bullet.cpp

示例7: Draw

/*
** Draws the meter on the double buffer
**
*/
bool CMeterRoundLine::Draw(Graphics& graphics)
{
	if (!CMeter::Draw(graphics)) return false;

	// Calculate the center of for the line
	int x = GetX();
	int y = GetY();
	double cx = x + m_W / 2.0;
	double cy = y + m_H / 2.0;

	double lineStart = ((m_CntrlLineStart) ? m_LineStartShift * m_Value : 0) + m_LineStart;
	double lineLength = ((m_CntrlLineLength) ? m_LineLengthShift * m_Value : 0) + m_LineLength;

	// Calculate the end point of the line
	double angle = ((m_CntrlAngle) ? m_RotationAngle * m_Value : m_RotationAngle) + m_StartAngle;
	double e_cos = cos(angle);
	double e_sin = sin(angle);

	REAL sx = (REAL)(e_cos * lineStart + cx);
	REAL sy = (REAL)(e_sin * lineStart + cy);
	REAL ex = (REAL)(e_cos * lineLength + cx);
	REAL ey = (REAL)(e_sin * lineLength + cy);

	if (m_Solid)
	{
		REAL startAngle = (REAL)(CONVERT_TO_DEGREES(m_StartAngle));
		REAL sweepAngle = (REAL)(CONVERT_TO_DEGREES(m_RotationAngle * m_Value));

		// Calculate the start point of the line
		double s_cos = cos(m_StartAngle);
		double s_sin = sin(m_StartAngle);

		//Create a path to surround the arc
		GraphicsPath path;
		path.AddArc((REAL)(cx - lineStart), (REAL)(cy - lineStart), (REAL)(lineStart * 2.0), (REAL)(lineStart * 2.0), startAngle, sweepAngle);
		path.AddLine((REAL)(lineStart * s_cos + cx), (REAL)(lineStart * s_sin + cy), (REAL)(lineLength * s_cos + cx), (REAL)(lineLength * s_sin + cy));
		path.AddArc((REAL)(cx - lineLength), (REAL)(cy - lineLength), (REAL)(lineLength * 2.0), (REAL)(lineLength * 2.0), startAngle, sweepAngle);
		path.AddLine(ex, ey, sx, sy);

		SolidBrush solidBrush(m_LineColor);
		graphics.FillPath(&solidBrush, &path);
	}
	else
	{
		Pen pen(m_LineColor, (REAL)m_LineWidth);
		graphics.DrawLine(&pen, sx, sy, ex, ey);
	}

	return true;
}
开发者ID:testaccountx,项目名称:testrepo,代码行数:54,代码来源:MeterRoundLine.cpp

示例8:

void
MFCArrangeView::DrawCursor(Graphics &pdc, CRect &clipBox)
{
//	cerr << "curser " << clipBox.left << ", " << cursorPx <<  ", " << clipBox.right << endl;
	bool	doDraw = true;
	if (clipBox != NULL) {
		if (clipBox.left > cursorPx || cursorPx > clipBox.right) {
			doDraw = false;
		}
	}
	if (doDraw) {
		Pen	cursorPen(AlphaColor(255, rgb_purple), 1);
		pdc.DrawLine(&cursorPen, cursorPx, clipBox.top, cursorPx, clipBox.bottom);
	}
}
开发者ID:dakyri,项目名称:qua,代码行数:15,代码来源:MFCArrangeView.cpp

示例9: drawShip

void TargetShip::drawShip(Graphics& graphics, Bullet* bullet)
{
	checkIfAlive(bullet);

	if(isAlive){
		position = position + velocity;
		graphics.SetColor(RGB(0,15,230));
		const unsigned int numLines = sizeof(TargetShipPoints) / sizeof(*TargetShipPoints);
		for(unsigned int x = 0; x < numLines; x++){
			const Vector2D& first = TargetShipPoints[x] + position ;
			const Vector2D& second = TargetShipPoints[(x+1) % numLines] + position;
			graphics.DrawLine(first.x, first.y,
				second.x, second.y);
		}
	}
	graphics.SetColor(RGB(100,175,230));
}
开发者ID:JMichaelWatson,项目名称:JWatsonGameSkeleton,代码行数:17,代码来源:TargetShip.cpp

示例10: DrawLine

void DrawLine(const Point &pt1, const Point &pt2, HDC hdcPaint, DashStyle dashStyle, Color clr, REAL width)
{
    Pen*         myPen;
    Graphics*    myGraphics;
    myPen = new Pen(clr, width);
    if(myPen)
    {
        myPen->SetDashStyle(dashStyle);
        myGraphics = new Graphics(hdcPaint);
        if(myGraphics)
        {
            myGraphics->DrawLine(myPen, pt1, pt2);
            delete myGraphics;
        }
        delete myPen;
    }
}
开发者ID:sakbhav,项目名称:PassWd_Mgr,代码行数:17,代码来源:aerosubc.cpp

示例11: DrawHotShape

void CToolRegularRuler::DrawHotShape(Graphics& graph)
{
	SolidBrush sbrush(Color::Green);
	Pen penDraw(Color::Blue, 2);
	penDraw.SetDashStyle(DashStyleDot);

	PointF pt((m_ptary[0].X + m_ptary[1].X) / 2, m_ptary[0].Y);
	
	graph.DrawLine(&penDraw, pt, m_HotPts.ptRotate);
	graph.FillEllipse(&sbrush, m_HotPts.ptRotate.X - HOTINTERVAL,
					  m_HotPts.ptRotate.Y - HOTINTERVAL,
					  2.0 * HOTINTERVAL, 2.0 * HOTINTERVAL);

	penDraw.SetDashStyle(DashStyleDash);
	penDraw.SetColor(Color::Red);

	graph.DrawRectangle(&penDraw, m_rcGrip.left, m_rcGrip.top, m_rcGrip.Width(), m_rcGrip.Height());
}
开发者ID:lilingshui,项目名称:code-refrence,代码行数:18,代码来源:CToolRegularRuler.cpp

示例12: Draw

/*
** Draws the meter on the double buffer
**
*/
bool CMeterLine::Draw(Graphics& graphics)
{
	int maxSize = m_GraphHorizontalOrientation ? m_H : m_W;
	if (!CMeter::Draw(graphics) || maxSize <= 0) return false;

	double maxValue = 0.0;
	int counter = 0;

	// Find the maximum value
	if (m_Autoscale)
	{
		double newValue = 0;
		std::vector< std::vector<double> >::const_iterator i = m_AllValues.begin();
		counter = 0;
		for (; i != m_AllValues.end(); ++i)
		{
			double scale = m_ScaleValues[counter];
			std::vector<double>::const_iterator j = (*i).begin();
			for (; j != (*i).end(); ++j)
			{
				double val = (*j) * scale;
				newValue = max(newValue, val);
			}
			++counter;
		}

		// Scale the value up to nearest power of 2
		if (newValue > DBL_MAX / 2.0)
		{
			maxValue = DBL_MAX;
		}
		else
		{
			maxValue = 2.0;
			while (maxValue < newValue)
			{
				maxValue *= 2.0;
			}
		}
	}
	else
	{
		if (m_Measure)
		{
			maxValue = m_Measure->GetMaxValue();

			std::vector<CMeasure*>::const_iterator i = m_Measures.begin();
			for (; i != m_Measures.end(); ++i)
			{
				double val = (*i)->GetMaxValue();
				maxValue = max(maxValue, val);
			}
		}

		if (maxValue == 0.0)
		{
			maxValue = 1.0;
		}
	}

	int x = GetX();
	int y = GetY();

	// Draw the horizontal lines
	if (m_HorizontalLines)
	{
		// Calc the max number of lines we should draw
		int maxLines = m_H / 4;	// one line per 4 pixels is max
		int numOfLines;

		// Check the highest power of 2 that fits in maxLines
		int power = 2;
		while (power < maxLines)
		{
			power *= 2;
		}

		numOfLines = ((int)maxValue % power) + 1;

		Pen pen(m_HorizontalColor);

		REAL Y;
		for (int j = 0; j < numOfLines; ++j)
		{
			Y = (REAL)((j + 1) * m_H / (numOfLines + 1));
			Y = y + m_H - Y - 1;
			graphics.DrawLine(&pen, (REAL)x, Y, (REAL)(x + m_W - 1), Y);	// GDI+
		}
	}

	// Draw all the lines

	if (m_GraphHorizontalOrientation)
	{
		const REAL W = m_W - 1.0f;
		counter = 0;
//.........这里部分代码省略.........
开发者ID:RichVRed,项目名称:rainmeter,代码行数:101,代码来源:MeterLine.cpp

示例13: MyPaint_Mem

void MyPaint_Mem(HDC my_hdc)
{
	Graphics *mygraphics;
	mygraphics = new Graphics(my_hdc);
	mygraphics->SetSmoothingMode(SmoothingModeAntiAlias);
	Pen *myRectangle_pen;
	Pen * my_inline_pen;

	Pen * CurePen;

	SolidBrush *BlackBrush;
	

	myRectangle_pen = new Pen(Color(255,0,255,255));
	my_inline_pen = new Pen(Color(255,220,220,220));

	REAL dashValues[2] = {5, 5};
	//Pen blackPen(Color(255, 0, 0, 0), 5);
	my_inline_pen->SetDashPattern(dashValues, 2);


	CurePen = new Pen(Graphic_Color[1],3.0f);
	PointF      pointF(0, 0);

	BlackBrush =new SolidBrush(Color(255,0,0,0));
	mygraphics->FillRectangle(BlackBrush,X_ORIGIN,Y_ORIGIN,X_WIDTH,Y_HIGHT);
	mygraphics->DrawRectangle(myRectangle_pen,X_ORIGIN,Y_ORIGIN,X_WIDTH,Y_HIGHT);

	SolidBrush *Static_blackground_Brush;
	Pen *mystaticRectangle_pen;
	mystaticRectangle_pen = new Pen(Color(255,0,0,0),2.0f);
	Static_blackground_Brush =new SolidBrush(Color(255,187,187,187));
	mygraphics->FillRectangle(Static_blackground_Brush,0,window_hight - 120,window_width,120);
	mygraphics->DrawRectangle(mystaticRectangle_pen,2,window_hight - 110,window_width-15,110 -30);

	SolidBrush  time_brush(Color(255, 225, 225, 225));
	FontFamily  fontFamily(_T("Times New Roman"));
	Gdiplus::Font        time_font(&fontFamily, 18, FontStyleRegular, UnitPixel);
	for(int i=0;i<x_line_scale;i++)				//画网格线
	{
		mygraphics->DrawLine(my_inline_pen,X_ORIGIN+(X_WIDTH/x_line_scale)*(i+1),Y_ORIGIN,X_ORIGIN+(X_WIDTH/x_line_scale)*(i+1),Y_ORIGIN + Y_HIGHT);
		CString strTime ;
		wchar_t temp_char[200];
		//time_t test = old_early_time;
		//CTime timeTest(test);
		time_t test ;
		CTime timeTest;

		switch(scale_type)
		{
		case _6_min:
			break;
		case _1_hour:
			test = old_early_time + i*600;

			timeTest = test ;

			strTime = timeTest.Format("%Y/%m/%d\r\n %H:%M:%S");
			pointF.X = X_ORIGIN - 40 + i*(X_WIDTH/x_line_scale);
			pointF.Y = Y_ORIGIN+Y_HIGHT + 10;
			mygraphics->DrawString(strTime, -1, &time_font, pointF, &time_brush);
			//old_early_time
			break;
		case _4_hour:
			break;
		case _12_hour:
			break;
		case _1_day:
			break;
		}

	}
	SolidBrush  unit_brush(Graphic_Color[1]);
	FontFamily  UnitfontFamily(_T("Times New Roman"));
	Gdiplus::Font        unitfont(&UnitfontFamily, 18, FontStyleRegular, UnitPixel);
	for(int i=0;i<=y_line_scale;i++)				//画网格线
	{
		CString Unit_value;
		if(i!=y_line_scale)
		mygraphics->DrawLine(my_inline_pen,X_ORIGIN,Y_ORIGIN+(Y_HIGHT/y_line_scale)*(1+i),X_WIDTH + X_ORIGIN,Y_ORIGIN+(Y_HIGHT/y_line_scale)*(1+i));

		if(i!=y_line_scale)
		Unit_value.Format(_T("%d"),(Total_SCALE/y_line_scale)*(y_line_scale-i));// = timeTest.Format("%Y/%m/%d\r\n %H:%M:%S");
		else
		Unit_value.Format(_T("%d"),Min_Scale_value);
		pointF.X = X_ORIGIN - 30;
		pointF.Y = Y_ORIGIN+ i*(Y_HIGHT/y_line_scale);
		mygraphics->DrawString(Unit_value, -1, &unitfont, pointF, &unit_brush);
		//swprintf_s(temp_char,200,L"%d",i*5);
		//mygraphics->DrawString(temp_char, -1, &font, pointF, &brush);

	}
	for (int i=1;i<=14;i++)
	{
		CString temp_item;
		temp_item.Format(_T("%x"),i);
		temp_item = temp_item.MakeUpper();

		SolidBrush  static_item_brush(Graphic_Color[i]);
		FontFamily  UnitfontFamily(_T("Arial Black"));
//.........这里部分代码省略.........
开发者ID:jay-github,项目名称:T3000_Building_Automation_System,代码行数:101,代码来源:BacnetGraphic.cpp

示例14: render

void cGameStateChart::render(Graphics &con){
 
  //Clear buffer and draw graphics
  con.ClearBuffer(0, 0, 0, 0);
  con.BeginDrawing();
  GRAPHIC_IMAGE gi;

  CGameData *pData = CGameData::Instance();

  //draw chart stuff
  gi = g_Sprite.GetSpriteData(48);//white square for chart background
  gi.scale = 5.05;
  con.RenderGraphicModulate(262 + pData->m_shockX, 134 + pData->m_shockX, gi, m_red, m_green, m_blue);

  //chart highlights and reference lines
  con.DrawRect(262, 134, 762, 634,255, 0, 0);
  con.DrawLine(512, 134, 512, 634, 0, 0, 120);
  con.DrawLine(262, 384, 762, 384, 0, 0, 120);
  
  //draw user interface on right side of chart
  con.DrawLine(780, 134, 800, 134, 0, 255, 0);//horizontal tick marks
  con.DrawLine(780, 249, 800, 249, 0, 255, 0);
  con.DrawLine(780, 269, 800, 269, 0, 255, 0);
  con.DrawLine(780, 384, 800, 384, 0, 255, 0);
  con.DrawLine(790, 134, 790, 249, 0, 255, 0);//vertical lines
  con.DrawLine(790, 269, 790, 384, 0, 255, 0);

  //draw range
  con.Draw2DTextValue("SCALE", (float)m_chartScale[m_chartScaleIndex], F_V20, 780, 249, 0, 255, 0);

  //zoom in and zoom out
  if(g_Global.g_mouse.x > 806 && g_Global.g_mouse.x < 1006 
    && ::GetActiveWindow() == g_hWnd){
    if(g_Global.g_mouse.y > 134 && g_Global.g_mouse.y < 249 && m_chartScaleIndex < 4){//zoom in
      gi = g_Sprite.GetSpriteData(30);
      con.RenderGraphicModulate(811,139,gi,m_red, m_green, m_blue);
    }
    else if(g_Global.g_mouse.y > 269 && g_Global.g_mouse.y < 384 && m_chartScaleIndex > 0){//zoom out
      gi = g_Sprite.GetSpriteData(29);
      con.RenderGraphicModulate(811,274,gi,m_red, m_green, m_blue);
    }
  }

  //display ship and sub data
//  CGameData *pData = CGameData::Instance();
  float posX = 0, posY = 0;
  float range = (float)m_chartScale[m_chartScaleIndex];

  //ships
  for(int i = 0; i < pData->m_targets.size(); ++i){
    posX = (pData->m_targets[i].m_posX - pData->m_Player.m_posX) * 250/range;
    posY = (pData->m_targets[i].m_posY - pData->m_Player.m_posY) * 250/range;

    if(pData->m_targets[i].m_bAlive == true &&  posX >= -250 && posX <= 250 && posY >= -250 && posY <= 250)//{
      con.DrawCircle(512 + posX,384 - posY, 255,0,0,(pData->m_targets[i].m_length/500) * (20000/(range * 2) ));
  }

  //torpedo
  for(int i = 0; i < pData->m_torpedos.size(); ++i){
    posX = (pData->m_torpedos[i].GetPositionX()- pData->m_Player.m_posX) * 250/range;
    posY = (pData->m_torpedos[i].GetPositionY() - pData->m_Player.m_posY) * 250/range;

    if(pData->m_torpedos[i].IsRunning() == true &&  posX >= -250 && posX <= 250 && posY >= -250 && posY <= 250)//{
      con.DrawCircle(512 + posX,384 - posY, 0, 0, 0,2 * (20000/(range * 8)));
  }

  //draw scope bearing line to indicate which target is being viewed
  float s = 0, t = 0;
  s = 512 + 250 * cos(pData->ConvertDegreesToRadians( pData->m_Player.m_heading + pData->m_scopeRotateAngle/5.689));
  t = 384 - 250 * sin(pData->ConvertDegreesToRadians( pData->m_Player.m_heading + pData->m_scopeRotateAngle/ 5.689));
  con.DrawLine(512,384,s,t, 0, 255,0);

  //draw sub in center of chart
  gi = g_Sprite.GetSpriteData(57);
  gi.rotationAngle =  pData->m_Player.m_heading * 3.141592654/180;
  gi.scale = 1;// (1000/range);
  con.RenderGraphicModulate(512 - (gi.width/2)* gi.scale, 384 - (gi.height/2) * gi.scale, gi, m_red, m_green, m_blue);

  //display short cuts
  gi = g_Sprite.GetSpriteData(36);//sonar
  con.RenderGraphicModulate(10,10,gi,m_red, m_green, m_blue);
  gi = g_Sprite.GetSpriteData(37);//radar
  con.RenderGraphicModulate(120,10,gi,m_red, m_green, m_blue);
  gi = g_Sprite.GetSpriteData(38);//conn selected
  con.RenderGraphicModulate(230,10,gi,m_red, m_green, m_blue);
  gi = g_Sprite.GetSpriteData(39);//fire control
  con.RenderGraphicModulate(694,10,gi,m_red, m_green, m_blue);
  gi = g_Sprite.GetSpriteData(40);//damage control
  con.RenderGraphicModulate(804,10,gi,m_red, m_green, m_blue);
  gi = g_Sprite.GetSpriteData(47);//chart
  con.RenderGraphicModulate(914,10,gi,m_red, m_green, m_blue);

  //draw tool tips for short cuts
  if(g_Global.g_mouse.y > 10 && g_Global.g_mouse.y < 130){
    //if(g_Global.g_mouse.x > 10 & g_Global.g_mouse.x < 104)
    //  con.Draw2DText("Sonar", F_V20, 20, 10, 0,255,255);
    //else if(g_Global.g_mouse.x > 120 & g_Global.g_mouse.x < 207)
    //  con.Draw2DText("Radar", F_V20, 130, 10, 0,255,255);
    if(g_Global.g_mouse.x > 230 & g_Global.g_mouse.x < 310)
      con.Draw2DText("Conn", F_V20, 240, 10, 0,255,255);
//.........这里部分代码省略.........
开发者ID:ChuckBolin,项目名称:Sinking,代码行数:101,代码来源:cGameStateChart.cpp

示例15: blackPen

void
MFCClipItemView::Draw(Graphics &dc, CRect &clipBox)
{
// !!!??? need to clip properly for short instances with long names
	cerr << "clip item draw " << item->sym->name << endl;
	Pen blackPen(Color(250, 0, 0, 0), 1);
	Pen redPen(Color(250, 238, 100, 100), 1);
	Pen orangePen(Color(200, 250, 150, 10), 1);
	SolidBrush blueBrush(Color(100, 100, 100, 238));
	SolidBrush blackBrush(Color(200, 0, 0, 0));
	SolidBrush orangeBrush(Color(190, 250, 150, 10));

	dc.DrawLine( &orangePen, bounds.left, 0, bounds.left, bounds.bottom);
	bool	isMarker = false;
	if (item != NULL && item->duration.ticks <= 0) {
		isMarker = true;
	}
	if (!isMarker) {
		dc.DrawLine( &orangePen, bounds.right, 0, bounds.right, bounds.bottom);
	}

	PointF	tri[3];

	Font	labelFont(L"Arial", 8.0, FontStyleRegular, UnitPoint, NULL);
	wstring nm;
	const char *cp = item->sym->uniqueName();
	while (*cp) {
		nm.push_back(*cp++);
	}
	PointF	p;
	UINT py = 0;
	do {
		if (!isMarker) {
			// a triangle bit
			tri[0].X = bounds.left; tri[0].Y = py;
			tri[1].X = bounds.left+6; tri[1].Y = py+3;
			tri[2].X = bounds.left; tri[2].Y = py+6;
			dc.FillPolygon(&orangeBrush, tri, 3);
		}

		p.X = bounds.left-1;
		p.Y = py+5;
		RectF	box;
		StringFormat	sff = StringFormatFlagsDirectionVertical;
		dc.MeasureString(nm.c_str(), -1, &labelFont, p, &sff, &box);
		dc.DrawString(nm.c_str(), -1, &labelFont, box,	&sff, &blackBrush);

		if (!isMarker) {
			// a nother triangle bit
			tri[0].X = bounds.right;
			tri[1].X = bounds.right-6;
			tri[2].X = bounds.right;
			dc.FillPolygon(&orangeBrush, tri, 3);

			p.X = bounds.right-10;
			p.Y = py+5;
			dc.MeasureString(nm.c_str(), -1, &labelFont, p, &sff, &box);
			dc.DrawString(nm.c_str(), -1, &labelFont, box,	&sff, &blackBrush);
		}
		py += editor->bounds.bottom;
	} while (py < bounds.bottom);

}
开发者ID:dakyri,项目名称:qua,代码行数:63,代码来源:MFCDataEditor.cpp


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