Skip to content

Instantly share code, notes, and snippets.

@praschl
Last active April 3, 2017 21:41
Show Gist options
  • Select an option

  • Save praschl/cd7b0d26c400af1d2d6027b0d8485367 to your computer and use it in GitHub Desktop.

Select an option

Save praschl/cd7b0d26c400af1d2d6027b0d8485367 to your computer and use it in GitHub Desktop.
Creates a bitmap, draws a grid on it, and copies it to clipboard... easier than installing whatever plugins into Paint.Net
const int IWidth = 320;
const int IHeight = 320;
const int RWidth = 16;
const int RHeight = 16;
Bitmap b = new Bitmap(IWidth, IHeight);
Graphics g = Graphics.FromImage(b);
g.Clear(Color.Transparent);
Brush[] brushes = { Brushes.Purple, Brushes.Green };
int brushIndex = 0;
for (int x = 0; x < IWidth; x += RWidth)
{
for (int y = 0; y < IHeight; y += RHeight)
{
Brush brush = brushes[brushIndex];
brushIndex = (brushIndex + 1) % 2;
g.FillRectangle(brush,x,y,32,32);
}
brushIndex = (brushIndex + 1) % 2;
}
Clipboard.SetImage(b);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment