Skip to content

Instantly share code, notes, and snippets.

@marcos-bah
Created August 5, 2021 13:22
Show Gist options
  • Save marcos-bah/b3e98203abeac1894d03733177f55aaa to your computer and use it in GitHub Desktop.
Save marcos-bah/b3e98203abeac1894d03733177f55aaa to your computer and use it in GitHub Desktop.
void CGR2020016324View::OnDraw(CDC* pDC)
{
CGR2020016324Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return;
// TODO: adicione o código de desenho para dados nativos aqui
CRect rectTela;
GetClientRect(&rectTela);
//define raio da orbita e do emoji
int raio = 100;
int raioEmoji = 50;
//define o centro da orbita e do emoji
CPoint centro(rectTela.Width() / 2, rectTela.Height() / 2);
CPoint centroEmoji(centro.x - raio, centro.y);
//cria a caneta para a orbita
CPen caneta(PS_DASH, 1, m_corLinhaOrbita), * oldPen;
//cria preenchiemento para o emoji
CBrush prenche(m_corEmoji), * oldBrush;
//sleciona a caneta para uso e guarda aantiga
oldPen = pDC->SelectObject(&caneta);
//cria a orbita solida
pDC->Ellipse(centro.x - raio, centro.y - raio, centro.x + raio, centro.y + raio);
//cria e seleciona a cor e o preenchimento para uso no emoji
CPen canetaEmoji(PS_SOLID, 1, RGB(0,0,0));
pDC->SelectObject(&canetaEmoji);
oldBrush = pDC->SelectObject(&prenche);
//cria as bordas do emoji
pDC->Ellipse(centroEmoji.x - raioEmoji, centroEmoji.y - raioEmoji, centroEmoji.x + raioEmoji, centroEmoji.y + raioEmoji);
//cria e usa o preenchimento do olho
CBrush prencheOlho(RGB(0,0,255));
pDC->SelectObject(&prencheOlho);
//cria o olho Direito do emoji
CPoint centroOlhoD(centroEmoji.x + (raioEmoji*0.35) , centroEmoji.y - (raioEmoji * 0.4));
pDC->Ellipse(centroOlhoD.x -8, centroOlhoD.y - 8, centroOlhoD.x + 8, centroOlhoD.y + 8);
//cria o olho Esquerdo do emoji
CPoint centroOlhoE(centroEmoji.x - (raioEmoji * 0.35), centroEmoji.y - (raioEmoji * 0.4));
pDC->Ellipse(centroOlhoE.x - 8, centroOlhoE.y - 8, centroOlhoE.x + 8, centroOlhoE.y + 8);
//cria a boca
//cria e usa o preenchimento da boca
CBrush prencheBoca(RGB(255, 0,0));
pDC->SelectObject(&prencheBoca);
int raioBoca = (int)((centroOlhoD.x - centroOlhoE.x)) + 8;
CPoint centroBoca(centroOlhoD.x, centroEmoji.y + (raioEmoji * 0.4));
pDC->Ellipse(centroBoca.x - raioBoca, centroBoca.y - 12, centroBoca.x + 8, centroBoca.y + 12);
CPen canetaBocaTriste(PS_SOLID, 1, m_corEmoji);
pDC->SelectObject(&canetaBocaTriste);
pDC->SelectObject(&prenche);
CPoint centroBocaTriste(centroBoca.x, centroBoca.y+2);
pDC->Ellipse(centroBocaTriste.x - raioBoca, centroBocaTriste.y - 8, centroBocaTriste.x + 8, centroBocaTriste.y + 12);
//reseta a caneta e prenchimento
pDC->SelectObject(oldPen);
pDC->SelectObject(oldBrush);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment