/* koor.c */ #include #include #include #include "skaala.h" #define MoveTo(h,x,y) MoveToEx(h,x,y,NULL) //char *WindowName = "Koordinaatisto"; void Draw_x_asteikko(HDC hDC, double x, double y,double xstep,double xmin,double xmax) { char numero[40] = ""; double ax; for ( ax = x; ax < xmax; ax+=xstep ) { sprintf(numero,"%lg",ax); TextOut(hDC, sx(ax)-5, sy(y)+15, numero,strlen(numero)); MoveTo(hDC, sx(ax), sy(y)-10); LineTo(hDC, sx(ax), sy(y)+10); } for ( ax = x; ax > xmin; ax-=xstep ) { sprintf(numero,"%lg",ax); TextOut(hDC, sx(ax)-5, sy(y)+15, numero,strlen(numero)); MoveTo(hDC, sx(ax), sy(y)-10); LineTo(hDC, sx(ax), sy(y)+10); } } #if 0 void Draw_y_asteikko(HDC hDC, int x, int y, int ystep,int ymin,int ymax) { char numero[4] = ""; int i = 0, apu_y = y-ystep; while(apu_y > ymin){ i++; sprintf(numero,"%d",i); TextOut(hDC, x-30 ,apu_y-10, numero,strlen(numero)); MoveTo(hDC, x-10, apu_y); LineTo(hDC, x+10, apu_y); apu_y -= ystep; } apu_y = y+ystep; i = 0; while(apu_y < ymax){ i--; sprintf(numero,"%d",i); TextOut(hDC, x+15, apu_y-10, numero,strlen(numero)); MoveTo(hDC, x-10, apu_y); LineTo(hDC, x+10, apu_y); apu_y += ystep; } } #endif void Koordinaatisto(HWND hWnd, HDC hDC, double x, double y, double xstep, double ystep, double xmin, double xmax, double ymin, double ymax) { #pragma argsused MoveTo(hDC, sx(xmin), sy(y)); /* piirretään x-akseli */ LineTo(hDC, sx(xmax), sy(y)); MoveTo(hDC, sx(x), sy(ymin)); /* piirretään y-akseli */ LineTo(hDC, sx(x), sy(ymax)); Draw_x_asteikko(hDC,x,y,xstep,xmin,xmax); // Draw_y_asteikko(hDC,x,y,ystep,ymin,ymax); }