Advertisement
Guest User

Untitled

a guest
May 24th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.41 KB | None | 0 0
  1. #include <windows.h>
  2. #include <mmsystem.h>
  3. #include <math.h>
  4. int xcz;
  5. int ycz;
  6. double alfa = 3.14 / 4;
  7. double alfa_pas = 0.2;
  8. double CoefDeScalare = 10;
  9. int cx, cy;
  10. double R = 50;
  11. int pas = 15;
  12. HFONT font;
  13. LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);
  14.  
  15. void Patrat(HDC hdc, POINT *ptt, int pass);
  16.  
  17. char szClassName[] = "WinApp";
  18.  
  19. int WINAPI WinMain(HINSTANCE hThisInstance,
  20.     HINSTANCE hPrevInstance,
  21.     LPSTR lpszArgument,
  22.     int nCmdShow)
  23. {
  24.     HWND hwnd;
  25.     MSG messages;
  26.     WNDCLASSEX wincl;
  27.  
  28.     wincl.hInstance = hThisInstance;
  29.     wincl.lpszClassName = szClassName;
  30.     wincl.lpfnWndProc = WindowProcedure;
  31.     wincl.style = CS_HREDRAW | CS_VREDRAW;
  32.     wincl.cbSize = sizeof(WNDCLASSEX);
  33.  
  34.     wincl.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  35.     wincl.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
  36.     wincl.hCursor = LoadCursor(NULL, IDC_ARROW);
  37.     wincl.lpszMenuName = NULL;
  38.     wincl.cbClsExtra = 0;
  39.     wincl.cbWndExtra = 0;
  40.  
  41.     wincl.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  42.  
  43.  
  44.  
  45.     if (!RegisterClassEx(&wincl))
  46.         return 0;
  47.  
  48.     hwnd = CreateWindowEx(
  49.         0,
  50.         szClassName,
  51.         (LP)"Lab 3 GC",
  52.         WS_OVERLAPPEDWINDOW,
  53.         CW_USEDEFAULT,
  54.         CW_USEDEFAULT,
  55.         1000,
  56.         500,
  57.         HWND_DESKTOP,
  58.         NULL,
  59.         hThisInstance,
  60.         NULL
  61.     );
  62.  
  63.     ShowWindow(hwnd, nCmdShow);
  64.     UpdateWindow(hwnd);
  65.  
  66.     while (GetMessage(&messages, NULL, 0, 0))
  67.     {
  68.  
  69.         TranslateMessage(&messages);
  70.         DispatchMessage(&messages);
  71.     }
  72.  
  73.     return messages.wParam;
  74. }
  75.  
  76. void Desenul(HDC hdc)
  77. {
  78.     HPEN hPen;
  79.     HBRUSH hBrush;
  80.     hPen = CreatePen(PS_SOLID, 5, RGB(255, 0, 255));
  81.     SelectObject(hdc, hPen);
  82.     POINT point[5];
  83.     int xc = xcz + R / 4 + 550, yc = ycz + R / 4 + 325;
  84.  
  85.  
  86.     DeleteObject(hPen);
  87.     SetBkMode(hdc, TRANSPARENT);
  88.     hPen = CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
  89.     SelectObject(hdc, hPen);
  90.     DeleteObject(hPen);
  91.     SetTextColor(hdc, RGB(255, 0, 255));
  92.     font = CreateFont(50, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  93.     SelectObject(hdc, font);
  94.     TextOut(hdc, 0, cy - 50, (LP)"  Examen GC", 52);
  95.     DeleteObject(font);
  96. }
  97. LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  98. {
  99.     HDC hdc;
  100.     RECT rect;
  101.     PAINTSTRUCT ps;
  102.     static int pas = 0, x = 0, y = 0, sk = 0;
  103.     HBRUSH hBrush;
  104.  
  105.  
  106.     static double   x1, y1;
  107.  
  108.     switch (message)
  109.     {
  110.     case WM_SIZE:
  111.         x1 = LOWORD(lParam) / 2;
  112.         y1 = HIWORD(lParam) / 2;
  113.         return 0;
  114.     case WM_CREATE:
  115.         SetTimer(hwnd, NULL, 100, NULL);
  116.         break;
  117.     case WM_PAINT:
  118.         hdc = BeginPaint(hwnd, &ps);
  119.         GetClientRect(hwnd, &rect);
  120.  
  121.  
  122.  
  123.         //pamintul...........................................
  124.         hBrush = CreateSolidBrush(RGB(0, 128, 0));
  125.         SelectObject(hdc, hBrush);
  126.         Rectangle(hdc, rect.left, (rect.bottom) / 2, rect.right, rect.bottom);
  127.         DeleteObject(hBrush);
  128.  
  129.  
  130.  
  131.         //cerul................................
  132.         hBrush = CreateSolidBrush(RGB(220, 255, 255));
  133.         SelectObject(hdc, hBrush);
  134.         Rectangle(hdc, rect.left, rect.top, rect.right, rect.bottom / 2);
  135.         DeleteObject(hBrush);
  136.  
  137.  
  138.  
  139.  
  140.         //acoperish...................................
  141.         SelectObject(hdc, CreateSolidBrush(RGB(255, 100, 0)));
  142.         POINT f4[3];
  143.         f4[0].x = 68;       f4[0].y = 282;
  144.         f4[1].x = 217;      f4[1].y = 194;
  145.         f4[2].x = 363;      f4[2].y = 282;
  146.  
  147.         Polygon(hdc, f4, 3);
  148.  
  149.         //casa...................................
  150.         SelectObject(hdc, CreateSolidBrush(RGB(0, 255, 2)));
  151.         Rectangle(hdc, 84, 282, 346, 483);
  152.  
  153.         //fereastra...................................
  154.         SelectObject(hdc, CreateSolidBrush(RGB(255, 255, 255)));
  155.         Rectangle(hdc, 159, 349, 247, 414);
  156.  
  157.  
  158.  
  159.         //soare...................................................................
  160.         SelectObject(hdc, CreateSolidBrush(RGB(255, 255, 0)));
  161.         Ellipse(hdc, 266 + pas, 46, 341 + pas, 121);
  162.  
  163.  
  164.         //copac
  165.         //tulpina...................................................................
  166.         SelectObject(hdc, CreateSolidBrush(RGB(255, 100, 0)));
  167.         Rectangle(hdc, 1104, 385, 1144, 488);
  168.  
  169.         //coroana...................................................................
  170.         SelectObject(hdc, CreateSolidBrush(RGB(100, 100, 0)));
  171.         Ellipse(hdc, 990, 150 + sk, 1270, 390);
  172.  
  173.  
  174.  
  175.  
  176.  
  177.         DeleteObject(hBrush);
  178.         Desenul(hdc);
  179.         EndPaint(hwnd, &ps);
  180.         break;
  181.     case WM_TIMER:
  182.         InvalidateRect(hwnd, NULL, TRUE);
  183.         pas += 5;
  184.         if (pas == 1000) pas = 0;
  185.         sk += 5;
  186.         if (sk == 50)sk = 0;
  187.         break;
  188.     case WM_DESTROY:
  189.         PostQuitMessage(0);
  190.         break;
  191.     case WM_CLOSE:
  192.         DestroyWindow(hwnd);
  193.         break;
  194.     default:
  195.         return DefWindowProc(hwnd, message, wParam, lParam);
  196.     }
  197.     return 0;
  198. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement