polyline函数在绘制连续的线段时,当出现不在画布上的坐标,也就是画布之外的点,会导致polyline函数不执行吗?在如下代码中,编译没有问题,但是结果没有出现图形,求解答。
#include <graphics.h> // 引用图形库头文件
#include<math.h>
#include<stdio.h>
#include<stdlib.h>
struct Point{
double x;
double y;
};
void Phan()//绘制函数
{
double x,y;
double tempx,tempy;
int n=0,i=0;
struct Point *point;
for(x = -8; x <= 8; x=x+0.001){
n++;}
point = (struct Point *)malloc(n * sizeof(struct Point));
for(x = -8; x <= 8; x=x+0.001) {
y=pow(x,2);
tempx = x;
tempy = y;
if (tempx >= 0){
tempx = x*50+500;
}else if(tempx<0){
tempx = 500+x*50;
}
point[i].x = tempx;
if (tempy >= 0){
tempy = 300 - y * 50;
}else if(tempy<0){
tempy = 300 - y * 50;
}
point[i].y = tempy;
i++;
}
polyline((POINT *)point, n);
free(point);
}
int main()
{
initgraph(1000, 600);// 初始化绘图窗口
setbkcolor(WHITE);
cleardevice();
Phan();
system("PAUSE");
return 0;
}