【发布时间】:2016-01-28 21:45:40
【问题描述】:
我正在尝试使用 GraphicsPath 绘制类似图像的“文件夹”。
我创建路径的功能如下:
Public Function FolderRect(ByRef r As Rectangle) As System.Drawing.Drawing2D.GraphicsPath
Dim p As New System.Drawing.Drawing2D.GraphicsPath
Dim iTabWidth As Integer = 30
Dim iTabHeight As Integer = 12
With p
Call p.AddLine(r.Left, r.Top, r.Left + iTabWidth, r.Top)
Call p.AddLine(r.Left + iTabWidth, r.Top, r.Left + iTabWidth, r.Top + iTabHeight)
Call p.AddLine(r.Left + iTabWidth, r.Top + iTabHeight, r.Right, r.Top + iTabHeight)
Call p.AddLine(r.Right, r.Top + iTabHeight, r.Right, r.Bottom)
Call p.AddLine(r.Right, r.Bottom, r.Left, r.Bottom)
Call p.AddLine(r.Left, r.Bottom, r.Left, r.Top)
Call p.CloseFigure()
End With
Return p
End Function
代码在我看来是正确的,但结果不是我所期望的:
(我使用图像编辑器创建了“正确”版本)。
这可能是 GraphicsPath 中的错误吗?
【问题讨论】:
-
我看错了。我以为你追求有角度/斜面的外观。如果我使用你的代码,我会得到方形标签。我不明白这将如何产生斜面
-
别修了,看起来不错。
-
通过绘制最后几行而不是 p.CloseFigure() 来尝试它可能不会像您期望的那样关闭它。
-
@Plutonix 你还有你的“有角度的”代码吗?我真的很想使用它。很遗憾,你删除了它。
-
@DerekTomes 删除 p.CloseFigure() 并没有改变任何东西。
标签: vb.net system.drawing graphicspath