2013-04-05 20 views
0

我正在处理.net2,所以没有访问.net3中的Line类,尽管我不知道这是否可行。如何展开一条线来制作一个矩形或区域

但我有一个线(2分)

,我想将它扩展到4点,即喜欢的drawLine宽度是否对图形, 但我无法找到一个简单的方法来获取区域/图形路径或矩形为此。

有人知道吗? 它可以在任何方向。

回答

0

我发现这样做的方法,

GraphicsPath gfxPath = new GraphicsPath(); 
gfxPath.AddLine(line.x1, line.y1, line.x2, line.y2); 
gfxPath.Widen(new Pen(Color.Blue, lineThickness));//lineThinkness is all that matters 
Region reg = new Region(gfxPath); 

if (reg.IsVisible(mousePoint)) // return true if the mousePoint is within the Region. 

这种加宽通过lineThickness行,然后你可以用它来检查,如果一个点或矩形等不到它。

相关问题