Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void paintStar(HWND* hWnd, int sx, int sy)
- {
- PAINTSTRUCT ps;
- HBRUSH hBrush = CreateSolidBrush(RGB(0,0,255));; //Öâåò ôîíà çâåçäû
- HDC hdc = BeginPaint(*hWnd, &ps);
- HPEN hpen = CreatePen(PS_SOLID, 2, RGB(0,0,0)); //Öâåò ëèíèé
- const int WIDTH = 400;
- const int HEIGHT = 300;
- POINT pt[5] = {
- {0, -100},
- {59, 95},
- {-95, -31},
- {95, -31},
- {-59, 95}
- };
- POINT pt1[5];
- SetMapMode(hdc, MM_ANISOTROPIC);
- SetWindowExtEx(hdc, WIDTH, -HEIGHT, NULL);
- SetViewportExtEx(hdc, sx/2, sy/2, NULL);
- SetViewportOrgEx(hdc, sx/2, sy/2, NULL);
- //
- //Polygon(hdc, pt, 5);
- int n = 6;
- double M_PI = 3.1415;
- double alpha = M_PI / n;
- for(int i = 0; i < n; i++)
- {
- hBrush = CreateSolidBrush(RGB(255, 255-255./n*i, 255-255./n*i));
- SelectObject(hdc, hBrush);
- for(int j = 0; j < 5; j++)
- {
- pt1[j].x = (pt[j].x * cos(alpha*i) - pt[j].y * sin(alpha*i)) + i * 10;
- pt1[j].y = (pt[j].x * sin(alpha*i) + pt[j].y * cos(alpha*i));
- }
- BeginPath(hdc);
- Polygon(hdc, pt1, 5);
- CloseFigure(hdc);
- EndPath(hdc);
- SelectObject(hdc, hBrush);
- SetPolyFillMode(hdc, WINDING);
- FillPath(hdc);
- }
- EndPaint(*hWnd, &ps);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement