コード例 #1
0
        Edge2 GetNextBoundaryFromEdge(Edge2 edge, ref Color[] pixels, int pWidth)
        {
            var x   = (int)(edge.b.x);
            var y   = (int)(edge.b.y);
            var hop = edge.b - edge.a;

            if (hop.y >= 0 && pixels[(y + 1) * pWidth + x] != pixels[(y + 1) * pWidth + x + 1])
            {
                return(new Edge2(edge.b, new Vector2(x, y + 1)));
            }
            if (hop.x >= 0 && pixels[(y + 1) * pWidth + x + 1] != pixels[y * pWidth + x + 1])
            {
                return(new Edge2(edge.b, new Vector2(x + 1, y)));
            }
            if (hop.y <= 0 && pixels[y * pWidth + x + 1] != pixels[y * pWidth + x])
            {
                return(new Edge2(edge.b, new Vector2(x, y - 1)));
            }
            if (hop.x <= 0 && pixels[y * pWidth + x] != pixels[(y + 1) * pWidth + x])
            {
                return(new Edge2(edge.b, new Vector2(x - 1, y)));
            }
            return(null);
        }
コード例 #2
0
 public bool Equals(Edge2 edge)
 {
     return(a.x == edge.a.x && a.y == edge.a.y && b.x == edge.b.x && b.y == edge.b.y);
 }