📄 plot.h
字号:
}
int PaperB ()
{
return B.PaperB;
}
template <class cr, class cg, class cb>
void Paper (cr r, cg g, cb b)
{
Calibrate (r, g, b);
B.Paper ((BYTE) r, (BYTE) g, (BYTE) b);
}
template <class cx, class cy, class cr, class cg, class cb>
inline void Plot (cx x, cy y, cr r, cg g, cb b)
{
Calibrate (r, g, b);
B.Plot ((int) x, (int) y, (BYTE) r, (BYTE) g, (BYTE) b);
}
template <class cx, class cy>
inline void Plot (cx x, cy y)
{
B.Plot ((int) x, (int) y, B.InkR, B.InkG, B.InkB);
}
template <class cx, class cy, class cr, class cg, class cb>
void Pixel (cx x, cy y, cr &r, cg &g, cb &b)
{
BYTE lr, lg, lb;
B.Pixel ((int) x, (int) y, lr, lg, lb);
r = (cr) lr;
g = (cg) lg;
b = (cb) lb;
}
template <class cx, class cy>
int PixelR (cx x, cy y)
{
return B.PixelR ((int) x, (int) y);
}
template <class cx, class cy>
int PixelG (cx x, cy y)
{
return B.PixelG ((int) x, (int) y);
}
template <class cx, class cy>
int PixelB (cx x, cy y)
{
return B.PixelB ((int) x, (int) y);
}
template <class cx, class cy, class cd>
void PlotPrint (cx x, cy y, cd n)
{
char a[128];
ostrstream b(a, 128);
b.seekp(0);
b << n << ends;
B.Print ((int)x, (int)y, (char *)a);
}
template <class cx, class cy, class cd, class cfn, class cs, class cb, class ci, class cu>
void FontPrint (cx x, cy y, cd n, cfn fn, cs s, cb b, ci i, cu u)
{
char a[16385];
ostrstream bb(a, 16384);
char fa[257];
ostrstream fb(fa, 256);
bb.seekp(0);
bb << n << ends;
fb.seekp (0);
fb << fn << ends;
B.FontPrint((int) x, (int) y, (char *) a, (char *) fa, (int) s, (BOOL) b, (BOOL) i,(BOOL) u);
}
template <class cd>
void _Print (cd n)
{
char a[128];
ostrstream b(a, 128);
b.seekp(0);
b << n << ends;
B.Print ((char *)a);
}
template <class cl, class cc>
void Locate (cl l, cc c)
{
B.Locate ((int) l, (int) c);
}
int LocateL ()
{
return B.LocateL;
}
int LocateC ()
{
return B.LocateC;
}
template <class cv>
void InputNumber (cv &v)
{
char InputBuffer[1024];
istrstream InputStream (InputBuffer, 1023);
B.Input (InputBuffer, 1023);
InputStream.seekg(0);
InputStream >> v;
}
void InputString (char* v, int l)
{
B.Input (v, l);
}
class ConsoleStream {};
ConsoleStream Print;
template <class ca>
ConsoleStream &operator << (ConsoleStream &c, ca a)
{
_Print (a);
return c;
}
template <class cw>
void SetLineWidth(cw w)
{
B.LineWidth = (int) w;
}
int LineWidth()
{
return B.LineWidth;
}
template <class cx1, class cy1, class cx2, class cy2, class cr, class cg, class cb>
void Line (cx1 x1, cy1 y1, cx2 x2, cy2 y2, cr r, cg g, cb b)
{
Calibrate (r, g, b);
B.Line ((int) x1, (int) y1, (int) x2, (int) y2, (BYTE) r, (BYTE) g, (BYTE) b);
}
template <class cx1, class cy1, class cx2, class cy2>
void Line (cx1 x1, cy1 y1, cx2 x2, cy2 y2)
{
B.Line ((int) x1, (int) y1, (int) x2, (int) y2, B.InkR, B.InkG, B.InkB);
}
template <class cxc, class cyc, class cra, class cr, class cg, class cb>
void Circle (cxc xc, cyc yc, cra ra, cr r, cg g, cb b)
{
Calibrate (r, g, b);
B.Circle ((int) xc, (int) yc, (int) ra, (BYTE) r, (BYTE) g, (BYTE) b);
}
template <class cxc, class cyc, class crc>
void Circle (cxc xc, cyc yc, crc rc)
{
B.Circle ((int) xc, (int) yc, (int) rc, B.InkR, B.InkG, B.InkB);
}
template <class cr, class cg, class cb>
void Cls (cr r, cg g, cb b)
{
Calibrate (r, g, b);
B.Cls((BYTE) r, (BYTE)g, (BYTE)b);
}
void Cls ()
{
B.Cls(B.PaperR, B.PaperG, B.PaperB);
}
template <class ca, class cr, class cg, class cb>
void Scroll (ca a, cr r, cg g, cb b)
{
Calibrate (r, g, b);
B.Scroll((int) a, (BYTE) r, (BYTE)g, (BYTE)b);
}
template <class ca>
void Scroll (ca a)
{
B.Scroll((int) a, B.PaperR, B.PaperG, B.PaperB);
}
template <class ca, class cr, class cg, class cb>
void Pann (ca a, cr r, cg g, cb b)
{
Calibrate (r, g, b);
B.Pann((int) a, (BYTE) r, (BYTE)g, (BYTE)b);
}
template <class ca>
void Pann (ca a)
{
B.Pann((int) a, B.PaperR, B.PaperG, B.PaperB);
}
template <class cx, class cy>
void TurtleAt (cx x, cy y)
{
B.TurtleAt ((double) x, (double) y);
}
template <class ca>
void TurtleTurn (ca a)
{
B.TurtleTurn ((double) a);
}
template <class ca>
void TurtleTurnTo (ca a)
{
B.TurtleTurnTo ((double) a);
}
void TurtleDown ()
{
B.TurtleDown ();
}
void TurtleUp ()
{
B.TurtleUp ();
}
BOOL TurtleIsDown ()
{
return B.TurtlePenTracing;
}
BOOL TurtleIsUp ()
{
return !B.TurtlePenTracing;
}
double TurtleX()
{
return B.TurtleX;
}
double TurtleY()
{
return B.TurtleY;
}
double TurtleDirection ()
{
return B.TurtleDirection;
}
template <class ca, class cr, class cg, class cb>
void TurtleMove (ca a, cr r, cg g, cb b)
{
Calibrate (r, g, b);
B.TurtleMove((double) a, (BYTE) r, (BYTE)g, (BYTE)b);
}
template <class ca>
void TurtleMove (ca a)
{
B.TurtleMove ((double) a, B.PaperR, B.PaperG, B.PaperB);
}
void RedrawNow ()
{
if (B.Rect.top <= B.Rect.bottom)
{
InvalidateRect(hWnd, &(B.Rect), FALSE);
B.Rect.top = 200;
B.Rect.left = 320;
B.Rect.bottom = 0;
B.Rect.right = 0;
}
}
void Refresh()
{
malabar Time = MilliTime ();
ThreadWantsRedrawNow = TRUE;
RefreshNextTime = Time + RefreshInterval;
ThreadShouldLoopWhilePainting = TRUE;
PostMessage(hWnd, WM_TIMER, 0,0);
while (ThreadShouldLoopWhilePainting);
}
void Quit()
{
ThreadSaysProgramMustStop = TRUE;
PostMessage(hWnd, WM_TIMER, 0,0);
while(TRUE);
}
template <class cv1, class cv2>
void Val (cv1 &v1, cv2 v2)
{
char a[16385];
ostrstream bo(a, 16383);
bo.seekp(0);
bo << v2 << ends;
istrstream bi(a);
bi.seekg(0);
bi >> v1;
}
void SuspendMyThread()
{
if (!ThreadSuspended)
{
SuspendThread(MyThread);
ThreadSuspended = TRUE;
}
}
void ResumeMyThread()
{
if (ThreadSuspended)
{
SuspendThread (MyThread);
ThreadSuspended = FALSE;
}
}
void ManageThreadAndRefresh()
{
malabar Time = MilliTime ();
static DidLastRefresh = FALSE;
if (ThreadWantsRedrawNow)
{
RedrawNow();
ThreadWantsRedrawNow = FALSE;
RefreshWaiting = FALSE;
RefreshNextTime = Time + RefreshInterval;
}
if (RefreshByUser)
{
if (Time >= RefreshNextTime)
{
RefreshWaiting = TRUE;
}
}
else
{
if (Time >= RefreshNextTime && !ThreadFinishedItsJob)
{
RedrawNow();
RefreshWaiting = FALSE;
RefreshNextTime = Time + RefreshInterval;
}
}
if (ThreadFinishedItsJob)
{
if (!RefreshByUser && !DidLastRefresh)
{
RedrawNow ();
DidLastRefresh = TRUE;
}
SuspendMyThread ();
}
if (ThreadSaysProgramMustStop)
{
SuspendMyThread ();
PostQuitMessage (0);
}
}
VOID CALLBACK TimerProc (HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime)
{
ManageThreadAndRefresh();
}
void MainThread ();
DWORD Thread (LPVOID data)
{
MainThread ();
ThreadFinishedItsJob = TRUE;
PostMessage(hWnd, WM_TIMER, 0,0);
while (TRUE);
ExitThread (0);
return 0;
}
// Prototype de la fonction de fen阾re
LONG FAR PASCAL WndProc(HWND, UINT, WPARAM, LPARAM);
// Fonction principale du programme
//int PASCAL WinMain(HANDLE hInstance, HANDLE hPrevInstance, // LPSTR lpszCmdLine, int nCmdShow)
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpszCmdLine, int nCmdShow)
{
Pi = atan (1) * 4;
// D閏laration des variables locales
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -