Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <mmsystem.h>
- #include <math.h>
- int xcz;
- int ycz;
- double alfa = 3.14 / 4;
- double alfa_pas = 0.2;
- double CoefDeScalare = 10;
- int cx, cy;
- double R = 50;
- int pas = 15;
- HFONT font;
- LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);
- void Patrat(HDC hdc, POINT *ptt, int pass);
- char szClassName[] = "WinApp";
- int WINAPI WinMain(HINSTANCE hThisInstance,
- HINSTANCE hPrevInstance,
- LPSTR lpszArgument,
- int nCmdShow)
- {
- HWND hwnd;
- MSG messages;
- WNDCLASSEX wincl;
- wincl.hInstance = hThisInstance;
- wincl.lpszClassName = szClassName;
- wincl.lpfnWndProc = WindowProcedure;
- wincl.style = CS_HREDRAW | CS_VREDRAW;
- wincl.cbSize = sizeof(WNDCLASSEX);
- wincl.hIcon = LoadIcon(NULL, IDI_APPLICATION);
- wincl.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
- wincl.hCursor = LoadCursor(NULL, IDC_ARROW);
- wincl.lpszMenuName = NULL;
- wincl.cbClsExtra = 0;
- wincl.cbWndExtra = 0;
- wincl.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
- if (!RegisterClassEx(&wincl))
- return 0;
- hwnd = CreateWindowEx(
- 0,
- szClassName,
- (LP)"Lab 3 GC",
- WS_OVERLAPPEDWINDOW,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- 1000,
- 500,
- HWND_DESKTOP,
- NULL,
- hThisInstance,
- NULL
- );
- ShowWindow(hwnd, nCmdShow);
- UpdateWindow(hwnd);
- while (GetMessage(&messages, NULL, 0, 0))
- {
- TranslateMessage(&messages);
- DispatchMessage(&messages);
- }
- return messages.wParam;
- }
- void Desenul(HDC hdc)
- {
- HPEN hPen;
- HBRUSH hBrush;
- hPen = CreatePen(PS_SOLID, 5, RGB(255, 0, 255));
- SelectObject(hdc, hPen);
- POINT point[5];
- int xc = xcz + R / 4 + 550, yc = ycz + R / 4 + 325;
- DeleteObject(hPen);
- SetBkMode(hdc, TRANSPARENT);
- hPen = CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
- SelectObject(hdc, hPen);
- DeleteObject(hPen);
- SetTextColor(hdc, RGB(255, 0, 255));
- font = CreateFont(50, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
- SelectObject(hdc, font);
- TextOut(hdc, 0, cy - 50, (LP)" Examen GC", 52);
- DeleteObject(font);
- }
- LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
- {
- HDC hdc;
- RECT rect;
- PAINTSTRUCT ps;
- static int pas = 0, x = 0, y = 0, sk = 0;
- HBRUSH hBrush;
- static double x1, y1;
- switch (message)
- {
- case WM_SIZE:
- x1 = LOWORD(lParam) / 2;
- y1 = HIWORD(lParam) / 2;
- return 0;
- case WM_CREATE:
- SetTimer(hwnd, NULL, 100, NULL);
- break;
- case WM_PAINT:
- hdc = BeginPaint(hwnd, &ps);
- GetClientRect(hwnd, &rect);
- //pamintul...........................................
- hBrush = CreateSolidBrush(RGB(0, 128, 0));
- SelectObject(hdc, hBrush);
- Rectangle(hdc, rect.left, (rect.bottom) / 2, rect.right, rect.bottom);
- DeleteObject(hBrush);
- //cerul................................
- hBrush = CreateSolidBrush(RGB(220, 255, 255));
- SelectObject(hdc, hBrush);
- Rectangle(hdc, rect.left, rect.top, rect.right, rect.bottom / 2);
- DeleteObject(hBrush);
- //acoperish...................................
- SelectObject(hdc, CreateSolidBrush(RGB(255, 100, 0)));
- POINT f4[3];
- f4[0].x = 68; f4[0].y = 282;
- f4[1].x = 217; f4[1].y = 194;
- f4[2].x = 363; f4[2].y = 282;
- Polygon(hdc, f4, 3);
- //casa...................................
- SelectObject(hdc, CreateSolidBrush(RGB(0, 255, 2)));
- Rectangle(hdc, 84, 282, 346, 483);
- //fereastra...................................
- SelectObject(hdc, CreateSolidBrush(RGB(255, 255, 255)));
- Rectangle(hdc, 159, 349, 247, 414);
- //soare...................................................................
- SelectObject(hdc, CreateSolidBrush(RGB(255, 255, 0)));
- Ellipse(hdc, 266 + pas, 46, 341 + pas, 121);
- //copac
- //tulpina...................................................................
- SelectObject(hdc, CreateSolidBrush(RGB(255, 100, 0)));
- Rectangle(hdc, 1104, 385, 1144, 488);
- //coroana...................................................................
- SelectObject(hdc, CreateSolidBrush(RGB(100, 100, 0)));
- Ellipse(hdc, 990, 150 + sk, 1270, 390);
- DeleteObject(hBrush);
- Desenul(hdc);
- EndPaint(hwnd, &ps);
- break;
- case WM_TIMER:
- InvalidateRect(hwnd, NULL, TRUE);
- pas += 5;
- if (pas == 1000) pas = 0;
- sk += 5;
- if (sk == 50)sk = 0;
- break;
- case WM_DESTROY:
- PostQuitMessage(0);
- break;
- case WM_CLOSE:
- DestroyWindow(hwnd);
- break;
- default:
- return DefWindowProc(hwnd, message, wParam, lParam);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement