Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void DrawStar(CDC* pDC, CPoint ptCenter, int radius1, int radius2, int n)
- {
- CBrush boja, *oldBrush;
- boja.CreateSolidBrush(RGB(255, 255, 0));
- CPen olovka, *oldPen;
- olovka.CreatePen(PS_SOLID, 4, RGB(0, 0, 0));
- XFORM forma, oldForm;
- forma.eDx = ptCenter.x;
- forma.eDy = ptCenter.y;
- forma.eM11 = 0;
- forma.eM12 = 0;
- forma.eM21 = 0;
- forma.eM22 = 0;
- float ugao = 360 / n;
- oldPen = pDC->SelectObject(&olovka);
- GetWorldTransform(pDC->m_hDC, &oldForm);
- SetWorldTransform(pDC->m_hDC, &forma);
- pDC->BeginPath();
- pDC->MoveTo(0, -radius1);
- forma.eDx = 0;
- forma.eDy = 0;
- forma.eM11 = cos((ugao / 2) * (pi / 180));
- forma.eM12 = sin((ugao / 2) * (pi / 180));
- forma.eM21 = -sin((ugao / 2) * (pi / 180));
- forma.eM22 = cos((ugao / 2) * (pi / 180));
- for (int i = 0; i < n * 2; i++)
- {
- ModifyWorldTransform(pDC->m_hDC, &forma, MWT_LEFTMULTIPLY);
- if (i % 2 == 0)
- pDC->LineTo(0, -radius2);
- else
- pDC->LineTo(0, -radius1);
- }
- oldBrush = pDC->SelectObject(&boja);
- pDC->EndPath();
- pDC->FillPath();
- pDC->SelectObject(oldPen);
- pDC->SelectObject(oldBrush);
- boja.DeleteObject();
- olovka.DeleteObject();
- SetWorldTransform(pDC->m_hDC, &oldForm);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement