Description
The SetPen
method configures the pen used for drawing operations on the Bitmap
object. This method allows you to specify the color and width of the pen, which will be used for subsequent drawing operations such as lines, rectangles, and other shapes.
Usage
To use the SetPen
method, you need to provide a Color
object representing the desired color of the pen and a float
value for the width of the pen. This method does not return a value.
Once the pen is set, any drawing operation performed on the Bitmap
will use the specified pen settings until they are changed again by calling SetPen
or another pen configuration method.
Example
// Create a new Bitmap instance
Bitmap bitmap = new Bitmap();
// Define a color for the pen
Color penColor = new Color(1.0f, 0.0f, 0.0f); // Red color
// Set the pen with the specified color and width
bitmap.SetPen(penColor, 2.0f);
// Now, any drawing operation will use the red pen with a width of 2.0
bitmap.DrawLine(new Vector2(10, 10), new Vector2(100, 100));