boarddraw.cpp

来自「实现Agent,绕墙走的功能,实现了图形化界面.点中按钮<AddWall&」· C++ 代码 · 共 77 行

CPP
77
字号
// BoardDraw.cpp: implementation of the BoardDraw class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Draw.h"
#include "BoardDraw.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

BoardDraw::BoardDraw() {
	m_pDC = NULL;
}

BoardDraw::~BoardDraw() {
	m_pDC = NULL;
}

BoardDraw::BoardDraw(CDC *pDC) {
	m_pDC = pDC;
}

void BoardDraw::SetForeColor(const COLORREF & color) {
	m_forecolor = color;
}

void BoardDraw::Rectangle(int x1, int y1, int x2, int y2) {
	CPen	thepen;
	thepen.CreatePen(PS_SOLID,1,m_forecolor);
	m_pDC->SelectObject(&thepen);
	CBrush	thebrush;
	thebrush.CreateSolidBrush(0xffffff);
	m_pDC->SelectObject(&thebrush);
	m_pDC->Rectangle(x1,y1,x2,y2);
}

void BoardDraw::DrawBlock(int x1, int y1, int x2, int y2) {
	CPen	thepen;
	thepen.CreatePen(PS_SOLID,1,0xff0000);
	m_pDC->SelectObject(&thepen);
	CBrush	thebrush;
	thebrush.CreateSolidBrush(0xF70894);
	m_pDC->SelectObject(&thebrush);
	m_pDC->Rectangle(x1,y1,x2,y2);
}

void BoardDraw::DrawWall(int x1, int y1, int x2, int y2) {
	CBrush	thebrush;
	thebrush.CreateSolidBrush(0x000011);
	m_pDC->SelectObject(&thebrush);
	CPen	thepen;
	thepen.CreatePen(PS_SOLID,1,0xff0000);
	m_pDC->SelectObject(&thepen);
	m_pDC->Rectangle(x1,y1,x2,y2);
}

void BoardDraw::Circle(int x1, int y1, int x2, int y2, int nOffset) {
	CPen	thepen;
	thepen.CreatePen(PS_SOLID,1,m_forecolor);
	m_pDC->SelectObject(&thepen);
	CBrush	thebrush;
	thebrush.CreateSolidBrush(0x0000ff);
	m_pDC->SelectObject(&thebrush);
	x1 = x1 + nOffset ;
	y1 = y1 + nOffset ;
	x2 = x2 - nOffset ;
	y2 = y2 - nOffset ;
	m_pDC->Ellipse(x1,y1,x2,y2);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?