首页 八连通区域代码

八连通区域代码

举报
开通vip

八连通区域代码#include "GL/glut.h" #include //#include typedef float Color[10]; rgbColorEqual(Color c1,Color c2) { if(abs(c1[1]-c2[1]) <0.001 && abs(c1[2]-c2[2]) <0.001 && abs(c1[0]-c2[0]) <0.001) return true; else return false; } void setPixel(int x,int y) {...

八连通区域代码
#include "GL/glut.h" #include //#include typedef float Color[10]; rgbColorEqual(Color c1,Color c2) { if(abs(c1[1]-c2[1]) <0.001 && abs(c1[2]-c2[2]) <0.001 && abs(c1[0]-c2[0]) <0.001) return true; else return false; } void setPixel(int x,int y) { glBegin(GL_POINTS); glVertex2i(x,y); glEnd(); } void getPixel(int x,int y,Color c) { glReadPixels(x,y,1,1,GL_RGB,GL_FLOAT,c); } void seedfill(int x,int y,Color nei,Color wai)//??×óì?3?1y3ì { Color interiorColor; getPixel(x,y,interiorColor); if (!(rgbColorEqual(interiorColor,wai)) && !(rgbColorEqual(interiorColor,nei))) { setPixel(x,y); glFlush(); seedfill(x,y+1, nei, wai); seedfill(x+1,y+1, nei, wai); seedfill(x+1,y, nei, wai); seedfill(x+1,y-1, nei, wai); seedfill(x,y-1, nei, wai); seedfill(x-1,y-1, nei, wai); seedfill(x-1,y, nei, wai); seedfill(x-1,y+1, nei, wai); } } void Init(void) { glClearColor(1.0,1.0,1.0,1.0); glMatrixMode(GL_PROJECTION); gluOrtho2D(0.0,400.0,0.0,300.0); //???¨??ê?μ???óò } void Display(void) { Color red={1.0,0.0,0.0},green={0.0,1.0,0.0};//?¨ò?oìé?£¨ì?3?é?nei£?oí?ìé?£¨±??μé?wai£? glClear(GL_COLOR_BUFFER_BIT); glColor3fv(red);//μ÷è?oìé??aμ±?°??í?é? glBegin(GL_LINE_LOOP);//??±??-ò?????óò glVertex2i(150,80); glVertex2i(150,150); glVertex2i(220,150); glVertex2i(220,80); glEnd(); glColor3fv(green);//μ÷è??ìé??aμ±?°??í?é? seedfill(180,110,red,green);//?aê?ì?3?1y3ì glFlush(); } void main(int argc, char *argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE); glutInitWindowPosition(100, 100); glutInitWindowSize(400, 300); glutCreateWindow("??×óì?3?"); Init(); glutDisplayFunc(Display); glutMainLoop(); }
本文档为【八连通区域代码】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_601191
暂无简介~
格式:doc
大小:16KB
软件:Word
页数:0
分类:互联网
上传时间:2019-01-17
浏览量:26