using System; namespace Prism.Glass { /// /// The checkerboard shown behind a transparent color. /// public static class Checkerboard { /// /// Fills the buffer with square cells alternating between two colors, the light one in the top left corner. /// /// The buffer isn't width by height pixels. /// The width, height or cell size is less than 1. public static void Fill(byte[] pixels, int width, int height, int cellSize, Color light, Color dark) { Rgba.CheckBuffer(pixels, width, height); if (cellSize < 1) { throw new ArgumentOutOfRangeException(nameof(cellSize), cellSize, "This has to be at least 1."); } for (int row = 0; row < height; row++) { for (int column = 0; column < width; column++) { bool isLight = (column / cellSize + row / cellSize) % 2 == 0; Rgba.Write(pixels, row * width + column, isLight ? light : dark); } } } } }