Advertisement
lofojak

5sPP3Task4

Oct 9th, 2024
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.44 KB | Source Code | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. #define _WIN32_WINNT 0X0A00
  5.  
  6. #include <windows.h>
  7. #include <time.h>
  8.  
  9. void WinShow(HDC dc)
  10. {
  11.     double x = 0.1, y = 0.1, xn, yn;
  12.     for (int i = 0; i < 10000; i++)
  13.     {
  14.         int t = rand() % 100;
  15.         if (t < 21)
  16.         {
  17.             xn = 0.088 * x + 0.521 * y + 0.785;
  18.             yn = -0.464 * x - 0.378 * y + 8.096;
  19.         }
  20.         else
  21.         {
  22.             xn = 0.824 * x + 0.281 * y - 1.882;
  23.             yn = -0.212 * x + 0.864 * y - 0.111;
  24.         }
  25.         x = xn; y = yn;
  26.         int a = (int)(400 + x * 30);
  27.         int b = (int)(400 - y * 30);
  28.         SetPixel(dc, a, b, RGB(140, 140, 255));
  29.     }
  30. }
  31.  
  32.  
  33. LRESULT WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
  34. {
  35.     if (message == WM_DESTROY)
  36.         PostQuitMessage(0);
  37.     else return DefWindowProcA(hwnd, message, wparam, lparam);
  38. }
  39. int main()
  40. {
  41.     srand(time(NULL));
  42.     WNDCLASSA wcl;
  43.     memset(&wcl, 0, sizeof(WNDCLASSA));
  44.     wcl.lpszClassName = "my_Window";
  45.     wcl.lpfnWndProc = WndProc;
  46.     RegisterClassA(&wcl);
  47.     HWND hwnd;
  48.     hwnd = CreateWindow(L"my_Window", L"        ", WS_OVERLAPPEDWINDOW, 10, 10, 800, 600, NULL, NULL, NULL, NULL);
  49.     HDC dc = GetDC(hwnd);
  50.     ShowWindow(hwnd, SW_SHOWNORMAL);
  51.     MSG msg;
  52.  
  53.     while (GetMessage(&msg, NULL, 0, 0))
  54.     {
  55.         TranslateMessage(&msg);
  56.         DispatchMessage(&msg);
  57.         WinShow(dc);
  58.     }
  59.     return 0;
  60. }
  61.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement