Creating a block arrow and filling with color

Blake81

Well-known member
Joined
Feb 23, 2006
Messages
304
Location
Georgia, USA
Programming Experience
1-3
I'm trying to use GDI to create a block arrow which I can then fill with color or a gradient brush. Since GDI doesn't have a DrawTriangle method, I was just drawing lines to try to get that shape. It seems that it was drawing one of the lines to extend all the way until it hit point 0,0. Also, is there any way to fill a custom shape and any way to merge a custom shape with a standard rectangle? The shape that I'm trying to accomplish is this.

arrows.jpg


I'd also like one with the triangle on only one end. I want to experiment with gradient brushes to see if I can make the fade move from one side to the other as the image redraws, sort of a progress bar. Thanks.
 
The Pen class can be used, it has StartCap and EndCap properties that can be for example ArrowAnchor, and it can be any size width. It can also be initialized with a Brush object, for example a LinearGradientBrush or TextureBrush for different fills. When pen is configured you can simply use Graphics.DrawLine method to draw the line with arrow ends.

Also look into GraphicsPath class, it is much like the Graphics class, where you instead of all the Draw.. methods got Add.. methods to add up figures. Then use the Graphics.DrawPath or FillPath methods to draw the shapes.
 
Back
Top