Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with drawing graphic

Status
Not open for further replies.

Sorwen

Technical User
Nov 30, 2002
1,641
0
0
US
I'm having a problem drawing this graphic:
point_wrong.png

For some reason I'm getting two points instead of just the one.

The code for it:
Code:
Private Function RoundedPoint(ByVal Rect As Rectangle, ByVal CornerSize As Integer) As GraphicsPath
        Dim _GraphicsPath As New Drawing2D.GraphicsPath()

       

        _GraphicsPath.AddArc(New Rectangle(40, 0, CornerSize, CornerSize), 180, 90)
        _GraphicsPath.AddLine(CornerSize, 0, (Rect.Width + 40) - CornerSize, 0)

        _GraphicsPath.AddArc(New Rectangle(Rect.Width - CornerSize, 0, CornerSize, CornerSize), -90, 90)
        _GraphicsPath.AddLine(Rect.Width, CornerSize, (Rect.Width + 40), Rect.Height - CornerSize)

        _GraphicsPath.AddArc(New Rectangle(Rect.Width - CornerSize, Rect.Height - CornerSize, CornerSize, CornerSize), 0, 90)
        _GraphicsPath.AddLine((Rect.Width + 40) - CornerSize, Rect.Height, CornerSize, Rect.Height)

        _GraphicsPath.AddArc(New Rectangle(40, Rect.Height - CornerSize, CornerSize, CornerSize), 90, 90)

        'Create Point
        Dim CenterPoint As Point = New Point(Rect.X, Rect.Height / 2)
        Dim Point3 As Integer = Rect.Height / 3
        _GraphicsPath.AddLine(40, Rect.Height - Point3, 0, CenterPoint.Y)
        _GraphicsPath.AddLine(0, CenterPoint.Y, 40, Point3)

        Return _GraphicsPath
    End Function
If I comment out the point part the shape is correct, jut a rounded rectangle with no points. What am I doing that is causing the wrong point?

-I hate Microsoft!
-Forever and always forward.
-My kingdom for a edit button!
 
Hi Sorwen,

I am not compleet sure but I think this is the line where it goes wrong.

_GraphicsPath.AddLine(Rect.Width, CornerSize, (Rect.Width + 40), Rect.Height - CornerSize)

You want to go down, but the X values are diffrent and should be the same.
(Rect.Width + 40) Should be Rect.Width

Good luck,

Ernst Jan
 
You were right. Thank you. I had been looking at the code so long I never noticed it. I also learned that technically I can remove all the +40. As long as the arcs are in the correct spot when it fills the shape it ignores any overage. I left all of the correct ones in just to be on the safe side though.

-I hate Microsoft!
-Forever and always forward.
-My kingdom for a edit button!
 
Hi Sorwen,

Glad to be of some help to you.

Greetings,
Ernst Jan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top