画Sin函数时有趣的现象
小甲鱼的代码如下case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
MoveToEx(hdc, 0, cyClient / 2, NULL);
LineTo(hdc, cxClient, cyClient / 2);
for (i = 0; i < NUM; i++)
{
apt.x = i * cxClient / NUM;
apt.y = (int)(cyClient / 2 * (1 - sin(TWOPI * i / NUM)));
}
PolylineTo(hdc, apt, NUM);
EndPaint(hwnd, &ps);
return 0;
自己敲的代码如下:
真的是非战之罪啊
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
MoveToEx(hdc,0,cyClient/2,NULL);
LineTo(hdc,cxClient,cyClient/2);
for(int i=0;i<NUM;i++)
{
apt.x=(cxClient/NUM*i;
apt.y=(int)(cyClient/2*(1-sin(TWOPI*i/NUM)));
}
PolylineTo(hdc,apt,NUM);
//PolylineTo(hdc,apt,NUM);
EndPaint(hWnd, &ps);
break;
就一处不同,就是在设置x坐标的地方
我的现象就是当x小于某个值时,会画不出来。
根本就不管用啊;
页:
[1]