public CheckeredGridElement(TileGridElement tile, bool invertEveryOtherTile)
     : base(tile.Width, tile.Height)
 {
     this.tile = tile;
     this.invertEveryOtherTile = invertEveryOtherTile;
     this.white = new WhiteGridElement(tile.Width, tile.Height);
 }
        private static void Apply(ExplicitOutlineShape target, TileGridElement tile, int xRight, int yTop, bool allLocations)
        {
            // Determine location of the center tile.
            int x = xRight;
            int y = yTop;

            // Determine bounding box of the center tile.
            Rectangle bbox = tile.BoundingBox;

            bbox.X += x;
            bbox.Y += y;

            // Move tile location to the left/top so that the bounding box is just inside of the shape.
            int i = bbox.Right / tile.Width;
            int j = bbox.Bottom / tile.Height;
            int k = (i + j) % 2;

            x      -= i * tile.Width;
            y      -= j * tile.Height;
            bbox.X -= i * tile.Width;
            bbox.Y -= j * tile.Height;

            // Apply the tile in all locations where the bounding box is still inside of the shape.
            for (i = 0; bbox.Left + i * tile.Width < target.XSize; i++)
            {
                for (j = 0; bbox.Top + j * tile.Height < target.YSize; j++)
                {
                    if (allLocations || (i + j + k) % 2 == 0)
                    {
                        tile.Apply(target, x + i * tile.Width, y + j * tile.Height);
                    }
                }
            }
        }
        /// <summary>
        /// Applies the given tile in a grid on the baseShape.
        /// </summary>
        /// <param name="gridTile"></param>
        private void ApplyCheckered(TileGridElement gridTile)
        {
            CheckeredGridElement shapeTile = new CheckeredGridElement(gridTile, false);

            this.Apply(shapeTile);
        }
        /// <summary>
        /// Returns the given tile applied in a grid.
        /// </summary>
        /// <param name="xSize"></param>
        /// <param name="ySize"></param>
        /// <param name="gridTile"></param>
        /// <param name="invertEveryOtherTile"></param>
        /// <returns></returns>
        private static GridOutlineShape CreateCheckeredInstance(int xSize, int ySize, TileGridElement gridTile, bool invertEveryOtherTile)
        {
            CheckeredGridElement shapeTile = new CheckeredGridElement(gridTile, invertEveryOtherTile);

            return(new GridOutlineShape(xSize, ySize, shapeTile));
        }