private void GetSquareFromStart(Pixel startPixel) { PixelSquare pixelSquare = new PixelSquare(new Dictionary <Vector2, Pixel>()); startPixel.GetConnectedPixels(this, pixelSquare); pixelSquares.Add(pixelSquare); qrSquares.Add(main.GetQRSquare(pixelSquare)); }
public void GetConnectedPixels(PixelGrouper grouper, PixelSquare pixelSquare) { List <Pixel> connectedPixels = new List <Pixel>(); Pixel foundPixel; if (grouper.PixelMap.TryGetValue(position + new Vector2(-1, 0), out foundPixel)) { connectedPixels.Add(foundPixel); } if (grouper.PixelMap.TryGetValue(position + new Vector2(1, 0), out foundPixel)) { connectedPixels.Add(foundPixel); } if (grouper.PixelMap.TryGetValue(position + new Vector2(0, -1), out foundPixel)) { connectedPixels.Add(foundPixel); } if (grouper.PixelMap.TryGetValue(position + new Vector2(0, 1), out foundPixel)) { connectedPixels.Add(foundPixel); } pixelSquare.AddPixel(this); this.color = pixelSquare.Color; //Spread :P if (connectedPixels.Count > 0) { isCorner = connectedPixels.Count <= 2; foreach (Pixel pixel in connectedPixels) { if (!pixelSquare.colided(pixel.position)) { pixel.GetConnectedPixels(grouper, pixelSquare); } } } }
public QRSquare GetQRSquare(PixelSquare pixelSquare) { QRSquare square = new QRSquare(map, pixelSquare.Corners); return(square); }