C++サイン線を引くインスタンスコード
1071 ワード
本文の例はC++が正弦波線を描く実現コードを述べて、みんなに参考にします.
主な機能コードは以下の通りです.
本稿で述べたことが皆さんのC++プログラム設計に役立つことを願っています.
主な機能コードは以下の通りです.
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
// TODO: ...
//
#define PI 3.1415926
#define SEGMENT 500
int cxClient,cyClient;
RECT rect;
::GetClientRect(hWnd, &rect);
cxClient = rect.right - rect.left;
cyClient = rect.bottom - rect.top;
POINT pt[SEGMENT];
for (int i=0;i {
pt[i].x = i * cxClient/SEGMENT; //cxClient SEGMENT
pt[i].y = (int)((cyClient/2)*(1 - sin(2 * PI * i/SEGMENT))); // sin(2pi) , Y , Y ,+cyClient/2
}
::Polyline(hdc, pt, SEGMENT); //
EndPaint(hWnd, &ps);
break;
本稿で述べたことが皆さんのC++プログラム設計に役立つことを願っています.