Graphics g = this.CreateGraphics(); Pen pen = new Pen(Color.Red, 2); g.DrawLine(pen, 0, 0, 100, 100);
Bitmap bitmap = new Bitmap(200, 200); Graphics g = Graphics.FromImage(bitmap); Brush brush = new SolidBrush(Color.Blue); g.FillRectangle(brush, 50, 50, 100, 100);These examples use the System.Drawing package library.