用於調試矩形位置的圖形化代碼
[編輯] [转简体] (简体译文)
|
作者:huidong
| 分類:【編程】EasyX
[
41 瀏覽
0 評論
17 贊
13 踩
]
概要
調試 BSch3V 所用代碼,可以顯示出矩形位置,略作記錄。
正文
#include <easyx.h> // 繪製帶文本的矩形 void drawrect_hd(LPCTSTR lpsz, COLORREF color, RECT rct) { const int ratio = 3; const int org_x = -100; const int org_y = -100; rct.left += org_x; rct.top += org_y; rct.right += org_x; rct.bottom += org_y; rct.left *= ratio; rct.top *= ratio; rct.right *= ratio; rct.bottom *= ratio; setlinecolor(color); settextcolor(color); setbkmode(TRANSPARENT); drawtext(lpsz, &rct, DT_CENTER | DT_VCENTER | DT_SINGLELINE); rectangle(rct.left, rct.top, rct.right, rct.bottom); } void PageInfo(LPCTSTR lpsz) { outtextxy(0, 0, lpsz); } void WaitForNextPage(bool clear) { getmessage(EX_KEY); Sleep(200); if (clear) cleardevice(); flushmessage(); } int main() { initgraph(640, 480); /*PageInfo(L"旋轉後,修正前"); { drawrect_hd(L"body", RED, { 490, 480, 510, 490 }); drawrect_hd(L"name", WHITE, { 466, 480, 508, 490 }); drawrect_hd(L"refnum", WHITE, { 512, 480, 522, 490 }); } WaitForNextPage(true); PageInfo(L"修正"); { drawrect_hd(L"body", RED, { 490, 480, 510, 490 }); drawrect_hd(L"name", WHITE, { 448, 480, 490, 490 }); drawrect_hd(L"refnum", WHITE, { 512, 480, 522, 490 }); } WaitForNextPage(true); PageInfo(L"吸附"); { drawrect_hd(L"body", RED, { 490, 480, 510, 490 }); drawrect_hd(L"name", WHITE, { 448, 480, 490, 490 }); drawrect_hd(L"refnum", WHITE, { 510, 480, 520, 490 }); } WaitForNextPage(true);*/ PageInfo(L""); { drawrect_hd(L"main", RED, { 190, 120, 220, 140 }); drawrect_hd(L"sub", WHITE, { 220, 126, 232, 137 }); } WaitForNextPage(true); return 0; }