コード例 #1
0
        Pixel[] StraightNeighbors(Pixel p)
        {
            List <Pixel> res = new List <Pixel>();

            if (p.y > PixelStart.y)
            {
                res.Add(p.Add(new Pixel(0, -1)));
            }
            if (p.y < PixelEnd.y)
            {
                res.Add(p.Add(new Pixel(0, 1)));
            }
            if (p.x > PixelStart.x)
            {
                res.Add(p.Add(new Pixel(-1, 0)));
            }
            if (p.x < PixelEnd.x)
            {
                res.Add(p.Add(new Pixel(1, 0)));
            }

            return(res.ToArray());
        }
コード例 #2
0
        Pixel[] DiagNeighbors(Pixel p)
        {
            List <Pixel> res = new List <Pixel>();

            if (p.y > PixelStart.y && p.x > PixelStart.x)
            {
                res.Add(p.Add(new Pixel(-1, -1)));
            }
            if (p.y < PixelEnd.y && p.x < PixelEnd.x)
            {
                res.Add(p.Add(new Pixel(1, 1)));
            }
            if (p.y < PixelEnd.y && p.x > PixelStart.x)
            {
                res.Add(p.Add(new Pixel(-1, 1)));
            }
            if (p.y > PixelStart.y && p.x < PixelEnd.x)
            {
                res.Add(p.Add(new Pixel(1, -1)));
            }

            return(res.ToArray());
        }