我有一些看起来像这样的代码:
GraphicsPath p = new GraphicsPath();
// Add some elements to p ...
// ...
g.FillPath(bgBrush, p);
// where g : Graphics and bgBrush : Brush
Run Code Online (Sandbox Code Playgroud)
这会产生如下情况:
### | ##| ## |
我怎样才能填写路径的确切补码?
期望的输出:
#| ## | # #|
我很惊讶到目前为止没有人回答 - 解决方案非常简单.只需在路径中添加一个Rectangle,内部的所有内容都将被还原.
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Graphics g = e.Graphics;
g.Clear(BackColor);
GraphicsPath p = new GraphicsPath();
// add the desired path
p.AddPie(100, 100, 100, 100, 0, 270);
// add the rectangle to invert the inside
p.AddRectangle(new Rectangle(50, 50, 200, 200));
g.FillPath(Brushes.Black, p);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1624 次 |
| 最近记录: |