Dec 19, 2013 05:46 PM
(This post was last modified: Dec 20, 2013 04:13 PM by Tedd.)
The use of it should be pretty self-explanatory, here is a preview:
![[Image: 5SfDE.png]](https://puu.sh/5SfDE.png)
I'm guessing a lot of you don't know why you would need this..
Well, to make curved buttons like this:
![[Image: 5SfGo.png]](https://puu.sh/5SfGo.png)
You need to use arcs (well, it's the easiest and only way I know).
However, say you didn't want ALL of the corners to be rounded? This function lets you do just that.
Source:
Yes, I know I don't need to use a class, but it's a whole lot more easy for me to understand it when I can say ".TopLeft = False", than just using AdvRectangle(New Rectangle(1,2,3,4), 5, False, False, True, False, 5)... So deal with it, or change it yourself.
EDIT:
Here is a new function called "Pill". It's used to create a "Pill" shape, which means a half-circle on the side of the button (as opposed to just a rounded edge).
![[Image: 5Tejf.png]](https://puu.sh/5Tejf.png)
Code:
If you want my complete Design Functions module (which makes GDI a hell of a lot easier) you can get it here:
http://pastebin.com/JXFrCdMU
![[Image: 5SfDE.png]](https://puu.sh/5SfDE.png)
I'm guessing a lot of you don't know why you would need this..
Well, to make curved buttons like this:
![[Image: 5SfGo.png]](https://puu.sh/5SfGo.png)
You need to use arcs (well, it's the easiest and only way I know).
However, say you didn't want ALL of the corners to be rounded? This function lets you do just that.
Source:
Code
Class CornerStyle
Public TopLeft As Boolean
Public TopRight As Boolean
Public BottomLeft As Boolean
Public BottomRight As Boolean
End Class
Public Function AdvRect(ByVal Rectangle As Rectangle, ByVal CornerStyle As CornerStyle, ByVal Curve As Integer) As GraphicsPath
Dim P As GraphicsPath = New GraphicsPath()
Dim ArcRectangleWidth As Integer = Curve * 2
If CornerStyle.TopLeft Then
P.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
Else
P.AddLine(Rectangle.X, Rectangle.Y, Rectangle.X + ArcRectangleWidth, Rectangle.Y)
End If
If CornerStyle.TopRight Then
P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
Else
P.AddLine(Rectangle.X + Rectangle.Width, Rectangle.Y, Rectangle.X + Rectangle.Width, Rectangle.Y + ArcRectangleWidth)
End If
If CornerStyle.BottomRight Then
P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
Else
P.AddLine(Rectangle.X + Rectangle.Width, Rectangle.Y + Rectangle.Height, Rectangle.X + Rectangle.Width - ArcRectangleWidth, Rectangle.Y + Rectangle.Height)
End If
If CornerStyle.BottomLeft Then
P.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
Else
P.AddLine(Rectangle.X, Rectangle.Y + Rectangle.Height, Rectangle.X, Rectangle.Y + Rectangle.Height - ArcRectangleWidth)
End If
P.CloseAllFigures()
Return P
End FunctionYes, I know I don't need to use a class, but it's a whole lot more easy for me to understand it when I can say ".TopLeft = False", than just using AdvRectangle(New Rectangle(1,2,3,4), 5, False, False, True, False, 5)... So deal with it, or change it yourself.
EDIT:
Here is a new function called "Pill". It's used to create a "Pill" shape, which means a half-circle on the side of the button (as opposed to just a rounded edge).
![[Image: 5Tejf.png]](https://puu.sh/5Tejf.png)
Code:
Code
Class PillStyle
Public Left As Boolean
Public Right As Boolean
End Class
Public Function Pill(ByVal Rectangle As Rectangle, ByVal PillStyle As PillStyle) As GraphicsPath
Pill = New GraphicsPath()
If PillStyle.Left Then
Pill.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, Rectangle.Height, Rectangle.Height), -270, 180)
Else
Pill.AddLine(Rectangle.X, Rectangle.Y + Rectangle.Height, Rectangle.X, Rectangle.Y)
End If
If PillStyle.Right Then
Pill.AddArc(New Rectangle(Rectangle.X + Rectangle.Width - Rectangle.Height, Rectangle.Y, Rectangle.Height, Rectangle.Height), -90, 180)
Else
Pill.AddLine(Rectangle.X + Rectangle.Width, Rectangle.Y, Rectangle.X + Rectangle.Width, Rectangle.Y + Rectangle.Height)
End If
Pill.CloseAllFigures()
Return Pill
End Function
Public Function Pill(ByVal X As Integer, ByVal Y As Integer, ByVal Width As Integer, ByVal Height As Integer, ByVal PillStyle As PillStyle)
Return Pill(New Rectangle(X, Y, Width, Height), PillStyle)
End FunctionIf you want my complete Design Functions module (which makes GDI a hell of a lot easier) you can get it here:
http://pastebin.com/JXFrCdMU
![[Image: 86251a37e635a21aea7eb7e014b0d820.gif]](https://i.gyazo.com/86251a37e635a21aea7eb7e014b0d820.gif)



![[Image: IQE6i8G.png]](https://i.imgur.com/IQE6i8G.png)

![[Image: Syr3DlV.png]](https://i.imgur.com/Syr3DlV.png)