扫描线填充2.doc_第1页
扫描线填充2.doc_第2页
扫描线填充2.doc_第3页
扫描线填充2.doc_第4页
扫描线填充2.doc_第5页
已阅读5页,还剩3页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

#include #include #include #define MAX_POINT 20 typedef struct int y_top; float x_int; int delta_y; float x_cps;EACH_ENTRY; void put_in_sides_list(int entry,int x1,int y1,int x2,int y2,int next_y);void sort_on_bigger_y(int n);void update_first_and_last(int count,int scan);void swap(EACH_ENTRY *x,EACH_ENTRY *y);void sort_on_x(int entry,int first_s);void process_x_intersections(int first_s,int last_s);void draw_lines(int scan,int x_int_c,int index);void update_sides_list(); EACH_ENTRY sidesMAX_POINT;int xMAX_POINT=0,210,240,230,350,380,340,200,180,150;int yMAX_POINT=0,410,370,200,410,340,140,180,120,300;int s_count,first_s,last_s,scan,bottom_s,x_int_c;main() int driver,mode; int v_count=9; driver=DETECT; initgraph(&driver,&mode,); setcolor(3); fill_area(v_count,x,y); getch(); closegraph(); fill_area(int count) sort_on_bigger_y(count); first_s=1; last_s=1; for(scan=sides1.y_top;scanbottom_s;scan-) update_first_and_last(count,scan); process_x_intersections(first_s,last_s); draw_lines(scan,x_int_c,first_s); update_sides_list(); void put_in_sides_list(int entry,int x1,int y1,int x2,int y2,int next_y) int maxy; float x2_temp,xch_temp; xch_temp=(float)(x2-x1)/(float)(y2-y1); x2_temp=x2; if(y2y1)&(y2next_y) y2-; x2_temp-=xch_temp; else if(y2next_y) y2+; x2_temp+=xch_temp; maxy=(y1y2)?y1:y2; while(entry1)&(maxysidesentry-1.y_top) sidesentry=sidesentry-1; entry-; sidesentry.y_top=maxy; sidesentry.delta_y=abs(y2-y1)+1; if(y1y2) sidesentry.x_int=x1; else sidesentry.x_int=x2_temp; sidesentry.x_cps=xch_temp;void sort_on_bigger_y(int n) int k,x1,y1; s_count=0; y1=yn; x1=xn; bottom_s=yn; for(k=1;kn+1;k+) if(y1!=yk) s_count+; put_in_sides_list(s_count,x1,y1,xk,yk,yk+1); else moveto(short)x1,480-(short)y1); lineto(short)xk,480-(short)y1); if(ykscan)&(last_sy_top;x-y_top=y-y_top;y-y_top=i_temp; f_temp=x-x_int;x-x_int=y-x_int;y-x_int=f_temp; i_temp=x-delta_y;x-delta_y=y-delta_y;y-delta_y=i_temp; f_temp=x-x_cps; x-x_cps=y-x_cps; y-x_cps=f_temp;void sort_on_x(int entry,int first_s) while(entryfirst_s)&(sidesentry.x_intsidesentry-1.x_int) swap(&sidesentry,&sidesentry-1); entry-; void process_x_intersections(int first_s,int last_s) int k; x_int_c=0; for(k=first_s;k0) x_int_c+; sort_on_x(k,first_s); void draw_lines(int scan,int x_int_c,int index) int k,x,x1,x2; for(k=1;k(int)(x_int_c/2+1.5);k+) while(sidesindex.delta_y=0) index+; x1=(int)(sidesindex.x_int+0.5); index+; while(sidesindex.delta_y=0) index+; x2=(int)(sidesindex.x_int+0.5); moveto(short)x1,480-(short)scan); lineto

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论