FUNCTION IsInArea(x,y : INTEGER) BOOLEAN;
BEGIN
IF COLOR(x,y)=BOUNDCOLOR) THEN
IsInArea = FALSE
ELSE IF COLOR(x,y)=COLOR(Qx,Qy) THEN
IsInArea = TRUE
ELSE
BEGIN
COLOR(x,y)=BOUNDCOLOR;
IF IsInArea(x+1,y) OR IsInArea(x,y+1)
OR IsInArea (x-1,y) OR IsInArea(x,y-1)THEN
IsInArea = TRUE
ELSE
IsInArea = FALSE;
END
END
补充前面我说的,那天手头没有资料
首先创建一个区域,推广一点,一个多边形,用:
HRGN CreatePolygonRgn(
CONST POINT *lppt, // pointer to array of points
int cPoints, // number of points in array
int fnPolyFillMode // polygon-filling mode
);
然后判断,用:
BOOL PtInRegion(
HRGN hrgn, // handle of region
int X, // x-coordinate of point
int Y // y-coordinate of point
);
就可以了。另外还可以用:
BOOL RectInRegion(
HRGN hrgn, // handle of region
CONST RECT *lprc // address of structure with rectangle
);
来判断,一个矩形是否在这个区域内。
我认为这是最简单的方法。
但,要问我算法的话:
我认为zhoukun666() 有理!