Advertisement
ithoran

Grafika zvezda

Nov 17th, 2017
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. void DrawStar(CDC* pDC, CPoint ptCenter, int radius1, int radius2, int n)
  2. {
  3. CBrush boja, *oldBrush;
  4. boja.CreateSolidBrush(RGB(255, 255, 0));
  5. CPen olovka, *oldPen;
  6. olovka.CreatePen(PS_SOLID, 4, RGB(0, 0, 0));
  7. XFORM forma, oldForm;
  8. forma.eDx = ptCenter.x;
  9. forma.eDy = ptCenter.y;
  10. forma.eM11 = 0;
  11. forma.eM12 = 0;
  12. forma.eM21 = 0;
  13. forma.eM22 = 0;
  14. float ugao = 360 / n;
  15. oldPen = pDC->SelectObject(&olovka);
  16.  
  17. GetWorldTransform(pDC->m_hDC, &oldForm);
  18.  
  19. SetWorldTransform(pDC->m_hDC, &forma);
  20. pDC->BeginPath();
  21. pDC->MoveTo(0, -radius1);
  22.  
  23. forma.eDx = 0;
  24. forma.eDy = 0;
  25. forma.eM11 = cos((ugao / 2) * (pi / 180));
  26. forma.eM12 = sin((ugao / 2) * (pi / 180));
  27. forma.eM21 = -sin((ugao / 2) * (pi / 180));
  28. forma.eM22 = cos((ugao / 2) * (pi / 180));
  29.  
  30. for (int i = 0; i < n * 2; i++)
  31. {
  32. ModifyWorldTransform(pDC->m_hDC, &forma, MWT_LEFTMULTIPLY);
  33. if (i % 2 == 0)
  34. pDC->LineTo(0, -radius2);
  35. else
  36. pDC->LineTo(0, -radius1);
  37. }
  38. oldBrush = pDC->SelectObject(&boja);
  39. pDC->EndPath();
  40. pDC->FillPath();
  41.  
  42. pDC->SelectObject(oldPen);
  43. pDC->SelectObject(oldBrush);
  44. boja.DeleteObject();
  45. olovka.DeleteObject();
  46.  
  47. SetWorldTransform(pDC->m_hDC, &oldForm);
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement