::
::
::
::
::
#include "graphics.h"
#include "math.h"
#define STEP 1
#define MYCOLOR WHITE
#define DELAY 10000
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
void initGraph()
{
int gmode,gdriver=DETECT;
initgraph(&gdriver, &gmode, "");
}
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
void blendingPoint(float x,float y,float path,int angle)
{
float i,stepX,stepY;
angle = 360 - (angle%360);
stepX = cos(angle*(M_PI/180.0))*STEP,stepY = sin(angle*(M_PI/180.0))*STEP;
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//*printf("%d,%f,%f",angle,stepX,stepY);
getch();*/
for(i=0;i<path;i+=STEP)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
putpixel(x += stepX,y += stepY,MYCOLOR);
delay(DELAY);
cleardevice();
}
}
void blendingLineMove(float x,float y,float dx,float dy,float length,int angle)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
{
dx /= (angle/STEP);dy /= (angle/STEP);
angle = 360 - (angle%360);
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//*printf("%d,%f,%f",angle,dx,dy);
printf("%f,%f",dx,dy);
getch();*/
while(angle < 360)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
cleardevice();
line(x += dx,y += dy,cos(angle*(M_PI/180.0))*length+x,sin(angle*(M_PI/180.0))*length+y);
delay(DELAY);
angle+=STEP;
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
void blendingLine(float x,float y,float length,int angle)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
{
blendingLineMove(x,y,0,0,length,angle);
}
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
void blendingpoly(float poly[],float x,float y,float dx,float dy,int angle)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
{
}
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
main()
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
{
float x,y,dx,dy,length,angle;
x=100;y=200;dx=300;dy=100;length=100;angle=90;
initGraph();
getch();
blendingPoint(x,y,length,angle);
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//*getch();*/
blendingLineMove(x,y,dx,dy,length,angle);
getch();
closegraph();
}
void blendingpoly(float poly[],float x,float y,float dx,float dy,int angle)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
{
float cosA,sinA;
angle = 360 - (angle%360);
angle /=STEP;
cosA = cos(angle*(M_PI/180.0));
sinA = sin(angle*(M_PI/180.0));
x = x*cosA - y*sinA;
y = x*sinA + y*cosA;
}
posted on
2006-10-08 11:42
FireYang
阅读(
300)
评论()
编辑
收藏
举报