计算机图形学出图c语言程序,计算机图形学程序(c语言实现)

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

e=-dx;

x=x0;y=y0;

while(x<=x1)

{

for(i=0;i<=2;i++)

for(j=0;j<=2;j++)

video_buffer[((y-1+i)<<8)+((y-1+i)<<6)+(x-1+j)]=4;

x=x+7;

e=e-2*dy;

if(e>0){y=y-7;e=e-2*dx;}

sleep(1);

}

}

knd4(struct windows *win)

{

unsigned char far *video_buffer=(char far *)0xa0000000;

int x,y,e,dx,dy,x1,y1,x0,y0,i,j;

int *q,*p;

q=(int *)malloc(42);/*为数组q[20]申请内存空间*/

for(i=0;i<21;i++)

q[i]=80+i*7;

p=(int *)malloc(42);/*为数组p[20]申请内存空间*/

for(i=0;i<21;i++)

p[i]=10+i*7;

drawnet(q,p,24,video_buffer);/*重画网格*/

x0=101;y0=136;

x1=150;y1=24;

dx=x1-x0;

dy=y1-y0;

e=-dy;

x=x0;y=y0;

while(y>=y1)

{

for(i=0;i<=2;i++)

for(j=0;j<=2;j++)

video_buffer[((y-1+i)<<8)+((y-1+i)<<6)+(x-1+j)]=4;

y=y-7;

e=e-2*dx;

if(e<0){x=x+7;e=e-2*dy;}

sleep(1);

}

}

/*circle选项触发函数*/

knd5(struct windows *win)

{

printf("kind5 pressed");

}

knd6(struct windows *win)

{

printf("kind6 pressed");

}

/*菜单Line按钮对象函数*/

menu1(struct windows *win)/*win为Line按钮对象*/

{

windows_ptr now;

windows_ptr pre;

windows_ptr head;

windows_ptr cho;

unsigned char far *video_buffer=(char far *)0xa0000000;

int i,j;

now=win;

cho=win->next;/*cho指向circle*/

if(win->status==MIN)/*菜单未打开*/

{

if(cho->status==MAX)

menu2(cho);

while(now->next!=NULL)

now=now->next;/*将now放在链表最后一个(窗口初始化的结构体->exit对象)*/

head=now;

pre=now;

for(i=0;i<=55;i++)

for(j=0;j<=43;j++)

video_buffer[((129+i)<<8)+((129+i)<<6)+(4+j)]=24;/*绘制菜单背景*/

now=(struct windows *)malloc(sizeof(struct windows));

initstruct(now,BUTTON,5,172,46,184,15,0,"kind1",0,knd1);

drawbartool(now,video_buffer);

now->father=win;

pre->next=now;

now->pre=head;

pre=now;

now=(struct windows *)malloc(sizeof(struct windows));

initstruct(now,BUTTON,5,158,46,170,15,0,"kind2",0,knd2);

drawbartool(now,video_buffer);

pre->next=now;

now->pre=pre;

pre=now;

now=(struct windows *)malloc(sizeof(struct windows));

initstruct(now,BUTTON,5,144,46,156,15,0,"kind3",0,knd3);

drawbartool(now,video_buffer);

pre->next=now;

now->pre=pre;

pre=now;

now=(struct windows *)malloc(sizeof(struct windows));

initstruct(now,BUTTON,5,130,46,142,15,0,"kind4",0,knd4);

drawbartool(now,video_buffer);

pre->next=now;

now->pre=pre;

pre=now;

pre->next=NULL;

win->status=MAX;

}

else if(win->status==MAX)

{

for(i=0;i<=55;i++)

for(j=0;j<=43;j++)

video_buffer[((129+i)<<8)+((129+i)<<6)+(4+j)]=0;

now=now->next;

now=now->next;

head=now;/*head指向Exit结构体*/

while(now->next!=NULL)

now=now->next;

while(now->pre!=head)

{

now=now->pre;

free(now->next);/*释放最后一个结构体空间*/

}

free(now);/*释放表尾*/

head->next=NULL;/*Exit指向空*/

win->status=MIN;

}

}

/*Circle对象函数*/

menu2(struct windows *win)/*win为Line按钮对象*/

{

windows_ptr now;

windows_ptr pre;

windows_ptr head;

windows_ptr cho;

unsigned char far *video_buffer=(char far *)0xa0000000;

int i,j;

now=win;

cho=win->pre;

if(win->status==MIN)/*菜单未打开*/

{

if(cho->status==MAX)

menu1(cho);

while(now->next!=NULL)

now=now->next;/*将now放在链表最后一个(窗口初始化的结构体->exit对象)*/

head=now;

pre=now;

for(i=0;i<=27;i++)

for(j=0;j<=52;j++)

video_buffer[((157+i)<<8)+((157+i)<<6)+(49+j)]=24;/*绘制菜单背景*/

now=(struct windows *)malloc(sizeof(struct windows));

initstruct(now,BUTTON,50,172,100,184,15,0,"kind1",0,knd5);

drawbartool(now,video_buffer);

pre->next=now;

now->pre=pre;

pre=now;

now=(struct windows *)malloc(sizeof(struct windows));

initstruct(now,BUTTON,50,158,100,170,15,0,"kind2",0,knd6);

drawbartool(now,video_buffer);

pre->next=now;

now->pre=pre;

pre=now;

pre->next=NULL;

win->status=MAX;

}

else if(win->status==MAX)

{

for(i=0;i<=27;i++)

for(j=0;j<=52;j++)

video_buffer[((157+i)<<8)+((157+i)<<6)+(49+j)]=0;

now=now->next;

head=now;/*head指向Exit结构体*/

while(now->next!=NULL)

now=now->next;

while(now->pre!=head)

{

now=now->pre;

free(now->next);/*释放最后一个结构体空间*/

}

free(now);/*释放表尾*/

head->next=NULL;/*Exit指向空*/

win->status=MIN;

}

}

********************************

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值