C#中填写的一切,但GraphicsPath的

编程入门 行业动态 更新时间:2024-10-24 10:19:30
本文介绍了C#中填写的一切,但GraphicsPath的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一些代码,看起来像:

GraphicsPath的P =新的GraphicsPath(); //添加一定元素为p ... // ... g.FillPath(bgBrush,P); //其中g:图形和bgBrush:刷

这导致东西,看起来像这样的:

### | ## | ## |

如何填充路径的准确补?

所需的输出

#| ## | ## |

解决方案

我很惊讶,没有人迄今回答 - 解决方案是非常简单的。只是一个矩形添加到路径和里面的一切得到恢复。

保护覆盖无效的OnPaint(PaintEventArgs的E) { base.OnPaint(E); 图形G = e.Graphics; g.Clear(背景色); GraphicsPath的P =新的GraphicsPath(); $ B $B∥加上所需的路径 p.AddPie(100,100,100,100,0,270); $ B $B∥加上矩形反转内侧 p.AddRectangle(新的Rectangle(50,50,200,200)); g.FillPath(Brushes.Black,P); }

I have some code that looks like that:

GraphicsPath p = new GraphicsPath(); // Add some elements to p ... // ... g.FillPath(bgBrush, p); // where g : Graphics and bgBrush : Brush

Which results in something that looks like this:

### | ##| ## |

How can I fill the exact complement of the path?

Desired output:

#| ## | # #|

解决方案

I'm surprised no one answered so far - the solution is pretty simple. Just add a Rectangle to the path and everything inside gets reverted.

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); }

更多推荐

C#中填写的一切,但GraphicsPath的

本文发布于:2023-11-09 10:21:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1572122.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:GraphicsPath

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!