#ifndef GRAPHFUNC_H_INCLUDED
#define GRAPHFUNC_H_INCLUDED
void parabola(HWND hwnd, int x, int y, int zoom, float vertex){
float x_=x, y_=y;
float step=0;

HDC hDC = GetDC (hwnd);

HPEN hPen = CreatePen (PS_SOLID, 1, RGB(255, 0, 0));
SelectObject (hDC, hPen);
HRGN hrgn = CreateRectRgn(20,20,560,520);
SelectClipRgn(hDC, hrgn);

for(int i=0; i<1000; i++ ){
MoveToEx(hDC, x_, y_, NULL);
LineTo(hDC, x+step*zoom, y-(step*step));
x_=x+step*zoom; y_=y-(step*step);
step+=0.1+vertex;}
x_=x, y_=y;
step=0;

for(int i=0; i<1000; i++ ){
MoveToEx(hDC, x_, y_, NULL);
LineTo(hDC, x-step*zoom, y-(step*step));
x_=x-step*zoom; y_=y-(step*step);
step+=0.1+vertex;}
x_=x, y_=y;
step=0;
DeleteObject(hrgn);
DeleteObject (hPen);
ReleaseDC (hwnd, hDC);
}

void hiperbola(HWND hwnd, int x, int y, int zoom, float vertex){
float x_=x, y_=y;
float step=0;

HDC hDC = GetDC (hwnd);

HPEN hPen = CreatePen (PS_SOLID, 1, RGB(255, 0, 0));
SelectObject (hDC, hPen);
HRGN hrgn = CreateRectRgn(20,20,560,520);
SelectClipRgn(hDC, hrgn);

for(int i=0; i<1000; i++ ){
MoveToEx(hDC, x_, y_, NULL);
LineTo(hDC, x+step*zoom, y-(step*step*step));
x_=x+step*zoom; y_=y-(step*step*step);
step+=0.1+vertex;}
x_=x, y_=y;
step=0;

for(int i=0; i<1000; i++ ){
MoveToEx(hDC, x_, y_, NULL);
LineTo(hDC, x-step*zoom, y+(step*step*step));
x_=x-step*zoom; y_=y+(step*step*step);
step+=0.1+vertex;}
DeleteObject(hrgn);
DeleteObject (hPen);
ReleaseDC (hwnd, hDC);
}

void line(HWND hwnd, int x, int y, int zoom, float step){
float x_=x, y_=y;
step=0;

HDC hDC = GetDC (hwnd);

HPEN hPen = CreatePen (PS_SOLID, 1, RGB(255, 0, 0));
SelectObject (hDC, hPen);
HRGN hrgn = CreateRectRgn(20,20,560,520);
SelectClipRgn(hDC, hrgn);

for(int i=0; i<1000; i++ ){
MoveToEx(hDC, x_, y_, NULL);
LineTo(hDC, x+i, y-i);
x_=x+i; y_=y-i;
step+=0.1;}
x_=x, y_=y;
step=0;

for(int i=0; i<1000; i++ ){
MoveToEx(hDC, x_, y_, NULL);
LineTo(hDC, x-i, y+i);
x_=x-i; y_=y+i;
step+=0.1;}
DeleteObject(hrgn);
DeleteObject (hPen);
ReleaseDC (hwnd, hDC);

}

void sin_func(HWND hwnd, int x, int y, float zoom, float vertex){
float x_=x, y_=y;

HDC hDC = GetDC (hwnd);

HPEN hPen = CreatePen (PS_SOLID, 1, RGB(255, 0, 0));
SelectObject (hDC, hPen);
HRGN hrgn = CreateRectRgn(20,20,560,520);
SelectClipRgn(hDC, hrgn);


for(int i=0; i<10000; i++ ){
MoveToEx(hDC, x_, y_, NULL);
LineTo(hDC, x+i*zoom/20, y-sin(i * 3.141592 / 180)*50);
x_=x+i*zoom/20; y_=y-sin(i * 3.141592 / 180)*50;}

x_=x, y_=y;

for(int i=0; i<10000; i++ ){
MoveToEx(hDC, x_, y_, NULL);
LineTo(hDC, x-i*zoom/20, y+sin(i * 3.141592 / 180)*50);
x_=x-i*zoom/20; y_=y+sin(i * 3.141592 / 180)*50;}

DeleteObject(hrgn);
DeleteObject (hPen);
ReleaseDC (hwnd, hDC);
}

void cos_func(HWND hwnd, int x, int y, float zoom, float vertex){
float x_=x, y_=y;

HDC hDC = GetDC (hwnd);

HPEN hPen = CreatePen (PS_SOLID, 1, RGB(255, 0, 0));
SelectObject (hDC, hPen);
HRGN hrgn = CreateRectRgn(20,20,560,520);
SelectClipRgn(hDC, hrgn);


for(int i=0; i<10000; i++ ){
MoveToEx(hDC, x_, y_, NULL);
LineTo(hDC, x+i*zoom/20, y-cos(i * 3.141592 / 180)*50);
x_=x+i*zoom/20; y_=y-cos(i * 3.141592 / 180)*50;}

x_=x, y_=y;

for(int i=0; i<10000; i++ ){
MoveToEx(hDC, x_, y_, NULL);
LineTo(hDC, x-i*zoom/20, y-cos(i * 3.141592 / 180)*50);
x_=x-i*zoom/20; y_=y-cos(i * 3.141592 / 180)*50;}
DeleteObject(hrgn);
DeleteObject (hPen);
ReleaseDC (hwnd, hDC);
}

void getfunc(HWND hwnd, int x, int y, int zoom, int vertex,int step,int func){
if(func==0)parabola(hwnd,x,y,zoom,vertex);
if(func==1)hiperbola(hwnd,x,y,zoom,vertex);
if(func==2)line(hwnd,x,y,zoom,step);
if(func==3)sin_func(hwnd,x,y,zoom,step);
if(func==4)cos_func(hwnd,x,y,zoom,step);
}
#endif // GRAPHFUNC_H_INCLUDED