How do I convert from system.drawing.color to system.drawing.brushes in vb.net?
Meta question: What is/why the difference between a brush/color/pen?
This should do it for you:
'just a solid brush:
Using br = New SolidBrush(Colors.Black)
e.Graphics.FillRectangle(br, New Rectangle(50, 50, 10, 10))
End Using
'A red -> orange gradient, at 45 degrees:
Using br = New LinearGradientBrush(new Rectangle(50, 50, 10, 10), Color.Red, Color.Orange, 25)
e.Graphics.FillRectangle(br, New Rectangle(50, 50, 10, 10))
End Using
A "Brush" is a style of fill drawing, incorporating both a Color and a Pattern. A Pen is similar to a Brush but defines a style of line drawing. To go from a Color to a Brush, you need to create a new Brush and give it the Color. The Brush class itself is abstract; its child classes specify various basic, customizable patterns of drawing. Pens are similar, but as lines are drawn as if they were filled rectangles, a Brush may be necessary to customize the "fill" of the line. The Pen object then has additional properties governing style that are specific to drawing a line. Take a look on MSDN: http://msdn.microsoft.com/en-us/library/d78x2d7s%28v=VS.71%29.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With