MFC画图-复刻一个logo

  • 原图:
    在这里插入图片描述
  • 程序实现:
    在这里插入图片描述
  • 步骤
     Step1:填充背景色
    在这里插入图片描述
     Step2:根据坐标点的位置画线
    在这里插入图片描述
     Step3:logo下文字
    在这里插入图片描述
void CFirstMFCLineView::OnLogoCreativeaudio()
{
	CPen m_pen[10];
	CBrush m_brush[5];
	m_pen[0].CreatePen(PS_SOLID, 1, RGB(255, 0, 0));     //红色实线,1像素宽---参数:样式、宽度、颜色
	m_pen[1].CreatePen(PS_INSIDEFRAME, 8, RGB(0, 0, 0));     //绿色实线,6像素宽
	m_pen[2].CreatePen(PS_COSMETIC, 1, RGB(255, 105, 13));     //绿色实线,6像素宽
	m_brush[0].CreateSolidBrush(RGB(255, 105, 13));
	m_pDC = new CClientDC(this);

	CBrush backBrush(RGB(55, 59, 60));
	CRect rect1(100, 60, 350, 330);
	m_pDC->GetClipBox(&rect1);
	//画需要的区域
	m_pDC->PatBlt(rect1.left, rect1.top, rect1.Width(), rect1.Height(), PATCOPY);

	CFont font;
	font.CreateFont(
		44,                                                  //   nHeight  
		22,                                                   //   nWidth  
		0,                                                   //   nEscapement
		0,                                                   //   nOrientation  
		FW_NORMAL,                                   //   nWeight  
		FALSE,                                           //   bItalic  
		FALSE,                                           //   bUnderline  
		0,                                                   //   cStrikeOut  
		ANSI_CHARSET,                             //   nCharSet  
		OUT_DEFAULT_PRECIS,                 //   nOutPrecision  
		CLIP_DEFAULT_PRECIS,               //   nClipPrecision  
		DEFAULT_QUALITY,                       //   nQuality  
		DEFAULT_PITCH | FF_SWISS,     //   nPitchAndFamily     
		_T("华文细黑"));

	m_pDC->SelectObject(&font);
	//CDC* pDC = this->GetDC();

	COLORREF color1 = RGB(255, 255, 255);
	COLORREF color2 = RGB(55, 59, 60);
	m_pDC->SetTextColor(color1);
	m_pDC->SetBkColor(color2);
	LPCWSTR text1 = TEXT("CREATIVE AUDIO");
	m_pDC->TextOut(73, 323, text1, lstrlen(text1));
	CRect rect(140, 200, 300, 300);
	rect.OffsetRect(80, 0);

	m_pDC->SelectObject(&m_pen[1]);
	m_pDC->Arc(143, 198, 300, 285, 288, 221, 205, 277);
	m_pDC->SelectObject(m_pen[2]);
	m_pDC->SelectObject(m_brush[0]);
	CPoint pt1[4] = { CPoint(250,93),CPoint(292,220) ,CPoint(287, 227),CPoint(250,113) };
	m_pDC->Polygon(pt1, 4);
	CPoint pt2[4] = { CPoint(210,278),CPoint(203,283) , CPoint(250,93),CPoint(250,113) };
	m_pDC->Polygon(pt2, 4);
}

猜你喜欢

转载自blog.csdn.net/weixin_43118073/article/details/105212118