1 / 6
文档名称:

精品PPT课件----图形学多边形区域填充.doc

格式:doc   页数:6
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

精品PPT课件----图形学多边形区域填充.doc

上传人:wz_198613 2014/9/20 文件大小:0 KB

下载得到文件列表

精品PPT课件----图形学多边形区域填充.doc

文档介绍

文档介绍:实验二:多边形的区域填充
一、实验目的与要求
通过实验,进一步理解和掌握几种常用多边形填充算法的基本原理
掌握多边形区域填充算法的基本过程
掌握在C/C++环境下用多边形填充算法编程实现指定多边形的填充。
二、实验内容
#include <>
#include <>
#include ""
#include <>
typedef float Color[3];
rgbColorEqual(Color c1,Color c2)
{
if(abs(c1[1]-c2[1])< && abs(c1[2]-c2[2])< && abs(c1[0]-c2[0])<)
return true;
else
return false;
}
void setPixel(GLint x, GLint y)
{
glBegin(GL_POINTS);
glVertex2i(x, y);
glEnd();
}
void getPixel(GLint x, GLint y, Color c)
{
glReadPixels(x,y,1,1,GL_RGB,GL_FLOAT,c);
}

void BoundaryFill(int x, int y,Color fillColor,Color borderColor)
{
Color currentColor;
getPixel(x,y,currentColor);
if((!rgbColorEqual(currentColor,fillColor))&&(!rgbColorEqual(currentColor,borderColor)))
{
//setColor(fillColor);
GLint x1;
GLint x2;
setPixel(x,y);
getPixel(x,y+1,currentColor);
if((!rgbColorEqual(currentColor,fillColor))&&(!rgbColorEqual(currentColor,borderColor)))
{
getPixel(x+1,y+1,currentColor);
if(rgbColorEqual(currentColor,borderColor))
{
BoundaryFill( x, (y+1), fillColor, borderColor);
}
}
getPixel(x,y-1,currentColor);
if((!rgbColorEqual(currentColor,fillColor))&&(!rgbColorEqual(currentColor,borderColor)))
{
getPixel(x+1,y-1,currentColor);
if(rgbColorEqual(currentColor,borderColor))
{
BoundaryFill( x, y-1, fillColor, borderColor);
}
}