Пример #1
0
        private static void SpreadTo(int i, int x, int y)
        {
            if (x != (i % sizeX))
            {
                throw new System.Exception();
            }
            if (y != (i / sizeX))
            {
                throw new System.Exception();
            }

            cells[i] = CELL_CLAIM;

            var spread = default(Spread);

            if (spreadCount >= spreads.Count)
            {
                spread = new Spread(); spreads.Add(spread);
            }
            else
            {
                spread = spreads[spreadCount];
            }

            spreadCount += 1;

            spread.i = i;
            spread.x = x;
            spread.y = y;

            currentIsland.AddPixel(minX + x, minY + y);
        }
Пример #2
0
        private static void TryFeather(Island island, int x, int y)
        {
            if (x >= 0 && y >= 0 && x < sizeX && y < sizeY)
            {
                var i = x + y * sizeX;

                if (cells[i] == CELL_EMPTY)
                {
                    cells[i] = CELL_CLAIM;

                    island.AddPixel(x, y);
                }
            }
            else
            {
                island.AddPixel(x, y);
            }
        }