Graphics 1 - Pens & Brushes - CSharp #3 ~ VBTheory™ Tutorials

Friday, October 3, 2014

Graphics 1 - Pens & Brushes - CSharp #3

Code:
Creating a pen
Pen p = new Pen(Color.Blue, 5);

Or:
Pen p = Pens.Blue;

Drawing a line:
e.Graphics.DrawLine(p, X1, Y1, X2, Y2);

Drawing a circle:
e.Graphics.DrawEllipse(p, X, Y, WIDTH, HEIGHT);

Drawing a rectangle:
e.Graphics.DrawRectangle(p, X, Y, WIDTH, HEIGHT):

Creating a brush:
Brush b = new SolidBrush(Color.Black);

Or:
Brush b = Brushes.Black;

Drawing text:
Font f = new Font("Segoe UI", 15, FontStyle.Italic | FontStyle.Bold);
e.Graphics.DrawString("YOUR TEXT HERE", f, b, X, Y);

Filling circle;
e.Graphics.FillEllipse(b, X, Y, WIDTH, HEIGHT);

Filling rectangle:
e.Graphics.FillRectangle(b, X, Y, WIDTH, HEIGHT);



Share