Learned to write code in pascal. In the course of study, I switched to C ++ and Visual Studio. In Borland Pascal there was a convenient canvas in which it was possible to draw shapes / graphics of functions, etc. is there an analogue in visual studio?
- Pseudography? - Vladimir Gamalyan
- No, you need to download additional libraries from outside - user272591
- @ user272591, what are the libraries? - Andrei Lobanovich
- @VladimirGamalyan yes, why not. - Andrei Lobanovich
|
1 answer
In Windows, you can draw on the window using GDI tools, the console window is not an exception. Naturally, such a decision would be intolerable. Example:
#include <windows.h> #include <iostream> #include <cmath> int main() { HWND hwnd = GetConsoleWindow(); HDC hdc = GetDC(hwnd); int x = 0; for (float i = 0; i < 3.14 * 10; i += 0.05) { SetPixel(hdc, x, 50 + 25 * cos(i), RGB(255, 255, 255)); x += 1; } ReleaseDC(hwnd, hdc); std::cin.ignore(); return 0; } Result:
In addition to setting the pixel in the presence of a large number of functions for drawing different primitives, using different brushes (thickness, pattern, etc.).
Attention! It works tolerably only in older versions of Windows (Windows XP). Do not use for modern systems starting with Vista.
- "Warning! It works tolerably only in older versions of Windows (Windows XP)." - In fact, it works in Win7. Naturally, before the first resizing window. - MSDN.WhiteKnight
|
