C语言课程设计-简单的图像演示|c语言程序代码编程小程序设计|c语言课程设计报告课程案例/********************************//* TurboC 2.0下运行通过 *//* 简单的图像演示 *//********************************/#include<conio.h>#include<stdio.h>#include<stdlib.h>#include<math.h>#include<graphics.h>#define RED 4#define LIGHTRED 12float rad=3.1415926/180.0;float k=640/480;void star();void shine(int R,int r,int data){ int x0[36],y0[36]; int x1[36],y1[36]; int i,data0=0; int X=getmaxx()/2,Y=getmaxy()/2; for(i=0;i<18;i++) {x0[i]=X+r*sin((data0+data)*rad); y0[i]=Y+k*r*cos((data0+data)*rad); x1[i]=X+R*sin((data0+data)*rad); y1[i]=Y+k*R*cos((data0+data)*rad); data+=20; setcolor(random(255)); delay(20); line(x0[i],y0[i],x1[i],y1[i]); } }main() {float x,y,Radius; int Driver=DETECT,Mode; int step=0; initgraph(&Driver,&Mode,"e:\\tc"); setbkcolor(1); x=getmaxx()/2;y=getmaxy()/2; Radius=getmaxy()/5; star(x,y,Radius); while(!kbhit()) {Radius=getmaxy()/4; step=20+random(40); shine(Radius,Radius+step,0);delay(100); step+=20;Radius+=20; shine(Radius,Radius+step,10);delay(100); step+=20;Radius+=20; shine(Radius,Radius+step,20);delay(200); } exit(0); }void star(x0,y0,R)float x0,y0,R;{ int x[5],y[5],x1[5],y1[5]; float r; int i,a=18; for(i=0;i<5;i++) {x[i]=x0+R*cos(a*rad)*k; y[i]=y0-R*sin(a*rad); a+=72; } r=R*(sin(18*rad)/sin(54*rad)); a=54; for(i=0;i<5;i++) {x1[i]=x0+r*cos(a*rad)*k; y1[i]=y0-r*sin(a*rad); a+=72; } setcolor(RED); line(x0,y0,x[0],y[0]); line(x0,y0,x1[4],y1[4]); line(x[0],y[0],x1[4],y1[4]); setfillstyle(SOLID_FILL,RED); floodfill(x1[4],y1[4]-1,RED); setcolor(RED); line(x0,y0,x[2],y[2]); line(x0,y0,x1[2],y1[2]); line(x[2],y[2],x1[2],y1[2]); setfillstyle(SOLID_FILL,RED); floodfill(x1[2],y1[2]-1,RED); setcolor(LIGHTRED); line(x[0],y[0],x1[0],y1[0]); line(x0,y0,x1[0],y1[0]); line(x0,y0,x[0],y[0]); setfillstyle(SOLID_FILL,LIGHTRED); floodfill(x1[0],y[0]+1,LIGHTRED); setcolor(RED); line(x0,y0,x1[0],y1[0]); line(x0,y0,x[1],y[1]); setfillstyle(SOLID_FILL,LIGHTRED); floodfill(x1[0]-1,y1[0],RED); setcolor(LIGHTRED); line(x[1],y[1],x1[1],y1[1]); line(x1[1],y1[1],x[2],y[2]); line(x0,y0,x[1],y[1]); line(x0,y0,x[2],y[2]); setcolor(LIGHTRED); line(x0,y0,x1[2],y1[2]); line(x0,y0,x[3],y[3]); line(x1[2],y1[2],x[3],y[3]); setfillstyle(SOLID_FILL,LIGHTRED); floodfill(x1[2]+1,y1[2]+1,LIGHTRED); floodfill(x1[1]+1,y1[1]+1,LIGHTRED); setcolor(RED); line(x0,y0,x[3],y[3]); line(x0,y0,x[4],y[4]); line(x[3],y[3],x1[3],y1[3]); line(x1[3],y1[3],x[4],y[4]); setfillstyle(SOLID_FILL,RED); floodfill(x1[3],y1[3]-1,RED); setcolor(LIGHTRED); line(x0,y0,x[4],y[4]); line(x0,y0,x1[4],y1[4]); line(x[4],y[4],x1[4],y1[4]); setfillstyle(SOLID_FILL,LIGHTRED); floodfill(x1[4]-1,y1[4]+1,LIGHTRED);}