我需要用抗锯齿填充一个复杂的区域。
该区域由许多旋转的矩形(如向日葵的花瓣)和一个中心圆组成。
区域不支持抗锯齿
所以我尝试了 FillPath 但没有填充矩形重叠的区域。(异或)
// Has alpha so FillPath-ing multiple times doesn't help
Color color = Color.FromArgb(128, 32, 64, 255);
Brush brush = new SolidBrush(color);
Region region = null;
//GraphicsPath bigPath = new GraphicsPath();
for (int i = 0; i < nPetals; i++)
{
GraphicsPath pat = new GraphicsPath();
Point p1, p2, p3, p4; // Actual code omitted
pat.AddPolygon(new[] { p1, p2, p3, p4 });
//bigPath.AddPolygon(new[] { p1, p2, p3, p4 });
if (region == null)
region = new Region(pat);
else region.Union(pat);
}
var pathCirc = new GraphicsPath();
pathCirc.AddEllipse(100,200,3,3);
region.Union(path);
g.FillRegion(brush, region); //Aliased
//g.FillPath(brush, bigPath); //XOR'ed
有没有办法 GraphicsPath.AddPolygon/AddEllipse() 非异或方式?