Exemplo n.º 1
0
    public static bool isIsolatedPoint(zzPoint pPoint,zzActiveChart tex)
    {
        var lDetectDirection = new DetectDirection();

        var lNextPoint = lDetectDirection.getOfsetPoint(pPoint);

        //下一个像素是否可用
        var isNextActivePiexl = tex.isInside(lNextPoint) && tex.isActive(lNextPoint);

        var lNextNextPoint = new zzPoint();
        bool isNextNextActivePiexl;

        for (int i = 0; i < 8;++i )
        {
            lDetectDirection.toNextDirection();
            //下下个像素是否可用
            lNextNextPoint = lDetectDirection.getOfsetPoint(pPoint);

            isNextNextActivePiexl = tex.isInside(lNextNextPoint)&&tex.isActive(lNextNextPoint);

            //连续两个像素可用,则此像素非孤立
            if(isNextActivePiexl && isNextNextActivePiexl)
                return false;
            isNextActivePiexl = isNextNextActivePiexl;

        }
        return true;
    }
Exemplo n.º 2
0
    //static bool isInsideImg(zzPoint pPoint,Texture2D tex)
    //{
    //    return pPoint.x >= 0
    //            && pPoint.x < tex.width
    //            && pPoint.y >= 0
    //            && pPoint.y < tex.height;
    //}
    static zzPoint[] beginEdge(zzActiveChart tex, zzPoint beginPosition, int[,] pProgressdMark, int pMark)
    {
        List<zzPoint> lOut = new List<zzPoint>();
        lOut.Add(beginPosition);
        pProgressdMark[beginPosition.x, beginPosition.y] = pMark;
        DetectDirection lDetectDirection = new DetectDirection();
        //int nowX=beginX,nowY=beginY;
        zzPoint lNowPoint = beginPosition;
        //int lNextX,lNextY;
        zzPoint lNextPoint;
        int lTotalNum = tex.width*tex.height;
        while(true)
        {

            lNextPoint = lDetectDirection.getOfsetPoint(lNowPoint);
            var lNextDirection = lDetectDirection.nextDirection();
            var lNextNextPoint = lNextDirection.getOfsetPoint(lNowPoint);

            if (tex.isInside(lNextPoint) && tex.isActive(lNextPoint))
            {

                lNowPoint = lNextPoint;

                if (lNowPoint == beginPosition)
                    break;
                pProgressdMark[lNowPoint.x, lNowPoint.y] = pMark;
                lOut.Add(lNowPoint);
                lDetectDirection.toPreDirection();
                lDetectDirection.toPreDirection();
            }
            else
            {
                //不可用,继续顺时针寻找
                lDetectDirection.toNextDirection();
            }

            if(lOut.Count>lTotalNum)
            {
                Debug.LogError("error ");
                break;
            }
        }

        return lOut.ToArray();
    }