VB.NET - Close gaps when drawing lines on an angle

Asked By Ken Ray on 05-May-15 08:23 PM

Using the following code:


Dim objGraphics As System.Drawing.Graphics

Dim pPen As New Pen(Brushes.Black)

pPen.LineJoin = Drawing2D.LineJoin.Bevel

pPen.Width = 48.0F

objGraphics.DrawLine(pPen, 1168, 793, 1025, 938) ' Horizontal ID=111

objGraphics.DrawLine(pPen, 675, 938, 1025, 938) ' Vertical ID-113

objBitmap.Save(Response.OutputStream, Drawing.Imaging.ImageFormat.Gif)

objBitmap.Save(Server.MapPath("x.jpg"), Drawing.Imaging.ImageFormat.Jpeg)

objBitmap.Dispose()

objGraphics.Dispose()

Produces the following image

How do I make it look like this with out modifying the x&y numbers

Robbe Morris replied to Ken Ray on 05-May-15 08:52 PM
I'm going to give you these two urls that may prove more helpful than my suggestion to draw a rectangle starting at the end of the bottom line long enough to meet up with the point of the upward angle.  If it is high enough to cover the top edge of the triangle, it should get you the visual you are after.  You could also draw a triangle in that slot as well.

The arc option in this first article may prove useful if you tweak it.

Sorry I can't be more helpful but I haven't draw anything sophisticated with GDI+ in a number of years.

https://www.nullskull.com/a/1619/net-draw-rounded-corners-on-a-rectangle.aspx

https://www.nullskull.com/a/1615/net-gdi-draw-tree--hierarchy.aspx