Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //// C Implementation for drawing circle
- //#include <graphics.h>
- //
- ////driver code
- //int main()
- //{
- // // gm is Graphics mode which is
- // // a computer display mode that
- // // generates image using pixels.
- // // DETECT is a macro defined in
- // // "graphics.h" header file
- // int gd = DETECT, gm;
- //
- // // initgraph initializes the
- // // graphics system by loading a
- // // graphics driver from disk
- // initgraph(&gd, &gm, "");
- //
- // // circle fuction
- // circle(250, 200, 50);
- //
- // getch();
- //
- // // closegraph function closes the
- // // graphics mode and deallocates
- // // all memory allocated by
- // // graphics system .
- // closegraph();
- //
- // return 0;
- //}
- #include <windows.h>
- #include <conio.h>
- #include <math.h>
- void main()
- {
- HWND hwnd;
- char Title[1024];
- GetConsoleTitle(Title, 1024); // Óçíàåì èìÿ îêíà
- hwnd = FindWindow(NULL, Title); // Óçíàåì hwnd îêíà
- RECT rc;
- GetClientRect(hwnd, &rc);
- int iWidth = rc.right;
- int iHeight = rc.bottom;
- HDC hdc = GetDC(hwnd); // Ïîëó÷àåì êîíòåêñò äëÿ ðèñîâàíèÿ
- HPEN p1, p2 = CreatePen(PS_SOLID, 2, RGB(255, 0, 0)), p3 = CreatePen(PS_SOLID, 2, RGB(200, 200, 255)); // Ñîçäàåì êðàñíîå ïåðî
- p1 = (HPEN)SelectObject(hdc, p2); // Çàíîñèì êðàñíîå ïåðî â êîíòåêñò ðèñîâàíèÿ
- int x = 0, y = 0, R = iWidth / 2;
- double fi = 0;
- do
- {
- x = R * cos(fi);
- y = R * sin(fi);
- MoveToEx(hdc, iWidth / 2, iHeight / 2, NULL);
- LineTo(hdc, x + iWidth / 2, iHeight / 2 - y);
- fi += 0.1;
- } while (fi < 6.28);
- (HPEN)SelectObject(hdc, p3);
- //fi = 0.1;
- //do
- //{
- // x = R * cos(fi);
- // y = R * sin(fi);
- // MoveToEx(hdc, iWidth / 2, iHeight / 2, NULL);
- // LineTo(hdc, x + iWidth / 2, iHeight / 2 - y);
- // fi += 0.2;
- //} while (fi < 6.28);
- HBRUSH oldb, hBlackBrush = CreateSolidBrush(RGB(100, 100, 255)), hOrangeBrush = CreateSolidBrush(RGB(253, 184, 19)), hEarthBrush = CreateSolidBrush(RGB(255, 0, 0));
- oldb = SelectObject(hdc, hBlackBrush);
- fi = 0;
- int size = 0;
- for (int k = 0; k < 50;k++) {
- for (int j =10; j > 0; j--) {
- for (int i = 1200 - (j * 20); i > 0; i -= 100) {
- Ellipse(hdc, -i+x + iWidth / 2, -i+iHeight / 2 - y, i + x + iWidth / 2, i + iHeight / 2 - y);
- //Ellipse(hdc, R - i, R - i, R + i, R + i);
- }
- x = (R/2) * cos(fi);
- y = (R/2) * sin(fi);
- //SelectObject(hdc, hOrangeBrush);
- //Ellipse(hdc, R-50, R-50, R+50 , R+50);
- (HPEN)SelectObject(hdc, p3);
- SelectObject(hdc, hEarthBrush);
- Ellipse(hdc, -50-1*size + x + iWidth / 2, -50 - 1 * size + iHeight / 2 - y, 50 + 1 * size + x + iWidth / 2, 50 + 1 * size + iHeight / 2 - y);
- SelectObject(hdc, hBlackBrush);
- fi += 0.1;
- //if (sin(fi)<0) { size++; }
- if (j<=5) { size+=5; }
- else { size-=5; }
- Sleep(100);
- }
- }
- SelectObject(hdc, oldb);
- SelectObject(hdc, p1); // Âîçâðàùàåì ñòàðîå ïåðî
- ReleaseDC(hwnd, hdc); // Îñâîáîæäàåì êîíòåêñò ðèñîâàíèÿ
- DeleteObject(p2); // Óäàëÿåì ñîçäàííîå ïåðî
- _getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement