有什么样的方法能够在vb.net中获取圆角矩形?
有什么样的方法能够在vb.net中获取圆角矩形?
'方法一
PrivateFunctionGetRoundedRectPath(ByValrectAsRectangle,ByValradiusAsInteger)AsSystem.Drawing.Drawing2D.GraphicsPath
rect.Offset(-1,-1)
DimRoundRectAsNewRectangle(rect.Location,NewSize(radius-1,radius-1))
DimpathAsNewSystem.Drawing.Drawing2D.GraphicsPath
path.AddArc(RoundRect,180,90)'左上角
RoundRect.X=rect.Right-radius'右上角
path.AddArc(RoundRect,270,90)
RoundRect.Y=rect.Bottom-radius'右下角
path.AddArc(RoundRect,0,90)
RoundRect.X=rect.Left'左下角
path.AddArc(RoundRect,90,90)
path.CloseFigure()
Returnpath
EndFunction
'方法二()
PrivateFunctionCreateRoundedRectPath(ByValrectAsRectangle,ByValradiusAsInteger)AsSystem.Drawing.Drawing2D.GraphicsPath
DimRoundRectAsNewSystem.Drawing.Drawing2D.GraphicsPath
RoundRect.AddLine(rect.Left+radius-2,rect.Top-1,rect.Right-radius,rect.Top-1)'顶端
RoundRect.AddArc(rect.Right-radius,rect.Top-1,radius,radius,270,90)'右上角
RoundRect.AddLine(rect.Right,rect.Top+radius,rect.Right,rect.Bottom-radius)'右边
RoundRect.AddArc(rect.Right-radius,rect.Bottom-radius,radius,radius,0,90)'右下角
RoundRect.AddLine(rect.Right-radius,rect.Bottom,rect.Left+radius,rect.Bottom)'底边
RoundRect.AddArc(rect.Left-1,rect.Bottom-radius,radius,radius,90,90)'左下角
RoundRect.AddLine(rect.Left-1,rect.Top+radius,rect.Left-1,rect.Bottom-radius)'左边
RoundRect.AddArc(rect.Left-1,rect.Top-1,radius,radius,180,90)'左上角
ReturnRoundRect
EndFunction
PrivateFunctionGetRoundedRectPath(ByValrectAsRectangle,ByValradiusAsInteger)AsSystem.Drawing.Drawing2D.GraphicsPath
rect.Offset(-1,-1)
DimRoundRectAsNewRectangle(rect.Location,NewSize(radius-1,radius-1))
DimpathAsNewSystem.Drawing.Drawing2D.GraphicsPath
path.AddArc(RoundRect,180,90)'左上角
RoundRect.X=rect.Right-radius'右上角
path.AddArc(RoundRect,270,90)
RoundRect.Y=rect.Bottom-radius'右下角
path.AddArc(RoundRect,0,90)
RoundRect.X=rect.Left'左下角
path.AddArc(RoundRect,90,90)
path.CloseFigure()
Returnpath
EndFunction
'方法二()
PrivateFunctionCreateRoundedRectPath(ByValrectAsRectangle,ByValradiusAsInteger)AsSystem.Drawing.Drawing2D.GraphicsPath
DimRoundRectAsNewSystem.Drawing.Drawing2D.GraphicsPath
RoundRect.AddLine(rect.Left+radius-2,rect.Top-1,rect.Right-radius,rect.Top-1)'顶端
RoundRect.AddArc(rect.Right-radius,rect.Top-1,radius,radius,270,90)'右上角
RoundRect.AddLine(rect.Right,rect.Top+radius,rect.Right,rect.Bottom-radius)'右边
RoundRect.AddArc(rect.Right-radius,rect.Bottom-radius,radius,radius,0,90)'右下角
RoundRect.AddLine(rect.Right-radius,rect.Bottom,rect.Left+radius,rect.Bottom)'底边
RoundRect.AddArc(rect.Left-1,rect.Bottom-radius,radius,radius,90,90)'左下角
RoundRect.AddLine(rect.Left-1,rect.Top+radius,rect.Left-1,rect.Bottom-radius)'左边
RoundRect.AddArc(rect.Left-1,rect.Top-1,radius,radius,180,90)'左上角
ReturnRoundRect
EndFunction