Plot a Sinewave to the Console
// plot a sinewave to the console window (cmd window)
// link with GDI32.lib or using Dev-C++ link libgdi32.a via
// Project>>Project Options>>Parameters>>Add Lib>>libgdi32.a
// this is a Windows Console Application vegaseat 06mar2005
#include <cstdio>
#include <cmath>
#include <windows.h>
int main(void)
{
int x, y;
COLORREF yellow = RGB(255,255,0);
COLORREF lightblue = RGB(173,216,230);
// make sure the names match
SetConsoleTitle("ConGraphics");
HWND hWnd = FindWindow(NULL, "ConGraphics");
HDC hDC = GetDC(hWnd);
// draw a yellow sine curve
for(x = 0; x < 700; x++)
{
// center at y = 200 pixels
y = (int)(sin(x/100.0)*100 + 200);
SetPixel(hDC, x, y, yellow);
}
// draw center line
for(x = 0; x < 700; x++)
{
SetPixel(hDC, x, 200, lightblue);
}
ReleaseDC(hWnd, hDC);
DeleteDC(hDC);
getchar(); // wait
return 0;
}
u_rangith
0
Newbie Poster
vallerie joy
0
Newbie Poster
kal_crazy
13
Junior Poster
jack.zgx
0
Newbie Poster
jack.zgx
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.