如何用另一个GraphicsPath剪接GraphicsPath以获得一个新的GraphicsPath
注1: SetClip()可以是一个完整的System.Drawing.Graphics对象,但这里需要的是某种与GraphicsPath相交以获得另一个GraphicsPath的方法。
注2:这里讨论的方法(交叉GraphicsPath对象)返回一个区域。在这里,我们期待一个GraphicsPath
发布于 2011-08-31 12:37:13
我做了一个快速的尝试,最接近的是:
var region = new Region(gp1);
region.Intersect(gp2);
var gpResult = new GraphicsPath();
gpResult.AddRectangles(region.GetRegionScans(new Matrix()));
gpResult.CloseAllFigures();
using (var br = new SolidBrush(Color.LightYellow))
{
e.Graphics.FillPath(br, gpResult);
//e.Graphics.DrawPath(Pens.Black, gpResult);
}这方面的问题是,GetRegionScans()给您返回了数千个矩形,而不仅仅是线条的不同点。取消对DrawPath方法的注释以了解我的意思。
有一个用于管理裁剪的开源库,它似乎是相当活跃的这里 (通过这个堆叠溢出问题找到)。
我没有这方面的经验,但它看起来能做你想做的事。
https://stackoverflow.com/questions/7255849
复制相似问题