Advertisement
Kolyach

4.5

Dec 2nd, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.12 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <Windows.h>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.     HWND hWnd = GetConsoleWindow(); //дескриптор окна
  9.     HDC hDC = GetDC(hWnd); //дескриптор контекста устройства
  10.     HPEN Pen = CreatePen(PS_SOLID, 2, RGB(255, 255, 255));
  11.  
  12.     float scale = 30;
  13.  
  14.     POINT horizontalAxisCoordinates = { 25, 230 };
  15.     POINT horizontalLineCoordinates = { 500, horizontalAxisCoordinates.y };
  16.  
  17.     POINT verticalAxisCoordinates = { 250, 50 };
  18.     POINT verticalLineCoordinates = { verticalAxisCoordinates.x, 390 };
  19.  
  20.     SelectObject(hDC, Pen);
  21.  
  22.     MoveToEx(hDC, horizontalAxisCoordinates.x, horizontalAxisCoordinates.y, NULL);
  23.     LineTo(hDC, horizontalLineCoordinates.x, horizontalLineCoordinates.y);
  24.  
  25.     MoveToEx(hDC, verticalAxisCoordinates.x, verticalAxisCoordinates.y, NULL);
  26.     LineTo(hDC, verticalLineCoordinates.x, verticalLineCoordinates.y);
  27.  
  28.     for (float x = -7; x <= 7; x += 0.01)
  29.     {
  30.         MoveToEx(hDC, (int)(scale * x + 250), (int)(-scale * sin(x*4) + 230), NULL);
  31.         LineTo(hDC, (int)(scale * x + 250), (int)(-scale * sin(x*4) + 230));
  32.     }
  33.  
  34.     ReleaseDC(hWnd, hDC);
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement