using (Graphics g = this.CreateGraphics()) { GraphicsPath gp1 = new GraphicsPath(); //创建一个不规则四边形 gp1.AddLines(new Point[]{ new Point(10,10), new Point(100,0), new Point(100,100), new Point(0,50) }); gp1.CloseFigure(); //封口 g.DrawPath(Pens.Blue, gp1); //绘制出四边形边框 GraphicsPath gp2 = new GraphicsPath(); //再次创建一个四边形 gp2.AddLines(new Point[]{ new Point(50,50), new Point(100,50), new Point(150,150), new Point(20,200) }); gp2.CloseFigure(); //封口 g.DrawPath(Pens.Blue, gp2); //绘制边框 Region rg1 = new Region(gp1); Region rg2 = new Region(gp2); rg1.Intersect(rg2); //取出交集 g.FillRegion(Brushes.Red, rg1); //绘制交集 g.DrawRectangle(Pens.Black, Rectangle.Round(rg1.GetBounds(g))); //绘制交集外接矩形 }你只有发挥吧!、、、
你可以吧四个边的的所有坐标点取到,然后和 另一个去比较如果 有相同的点就证明有 交集。我记得数学中 有 2条线段 求交集的 公式,你可以用下,http://blog.csdn.net/ly92are1999/article/details/6840534
using (Graphics g = this.CreateGraphics()) {
GraphicsPath gp1 = new GraphicsPath(); //创建一个不规则四边形
gp1.AddLines(new Point[]{
new Point(10,10),
new Point(100,0),
new Point(100,100),
new Point(0,50)
});
gp1.CloseFigure(); //封口
g.DrawPath(Pens.Blue, gp1); //绘制出四边形边框
GraphicsPath gp2 = new GraphicsPath(); //再次创建一个四边形
gp2.AddLines(new Point[]{
new Point(50,50),
new Point(100,50),
new Point(150,150),
new Point(20,200)
});
gp2.CloseFigure(); //封口
g.DrawPath(Pens.Blue, gp2); //绘制边框 Region rg1 = new Region(gp1);
Region rg2 = new Region(gp2);
rg1.Intersect(rg2); //取出交集
g.FillRegion(Brushes.Red, rg1); //绘制交集
g.DrawRectangle(Pens.Black, Rectangle.Round(rg1.GetBounds(g))); //绘制交集外接矩形
}你只有发挥吧!、、、
http://blog.csdn.net/mngzilin/article/details/7468031