GDI+:为什么 FillRectangle 在玻璃上是透明的,而 FillEllipse 是不透明的?

发布于 2024-10-04 04:55:08 字数 1912 浏览 1 评论 0原文

我正在玻璃上画一个矩形和一个椭圆形。

brush = new SolidBrush(0xFF000000); //solid (i.e. non-opaque) black
graphics.FillRectangle(brush, x,    y,    30, 30);
graphics.FillEllipse(brush,   x+33, y-15, 30, 30);
  • 使用椭圆绘制:不透明
  • 使用矩形绘制:不透明

alt text

这是怎么回事?

您可以看到同样的情况也适用于其他颜色:

brush = new SolidBrush(0xFFff0000); //solid (i.e. non-opaque) red
graphics.FillRectangle(brush, x, y,    30, 30);
graphics.FillEllipse(brush,   x, y+33, 30, 30);

brush = new SolidBrush(0xFF00ff00); //solid (i.e. non-opaque) green
graphics.FillRectangle(brush, x, y,    30, 30);
graphics.FillEllipse(brush,   x, y+33, 30, 30);

brush = new SolidBrush(0xFF0000ff); //solid (i.e. non-opaque) blue
graphics.FillRectangle(brush, x, y,    30, 30);
graphics.FillEllipse(brush,   x, y+33, 30, 30);

brush = new SolidBrush(0xFFffffff); //solid (i.e. non-opaque) white
graphics.FillRectangle(brush, x, y,    30, 30);
graphics.FillEllipse(brush,   x, y+33, 30, 30);

alt text

结论:为什么:

  • <使用不透明颜色的 code>FillEllipse 绘制不透明
  • FillRectangle 使用不透明颜色绘制部分透明

注意:这个问题几乎与我的其他问题。 除了这个问题集中在 FillRectangle 和之间的区别 FillEllipse - 而这个问题 处理*如何绘制不透明颜色 在玻璃上。

另请参阅

i'm drawing a rectangle, and an ellipse, on glass.

brush = new SolidBrush(0xFF000000); //solid (i.e. non-opaque) black
graphics.FillRectangle(brush, x,    y,    30, 30);
graphics.FillEllipse(brush,   x+33, y-15, 30, 30);
  • drawing with ellipse: it's opaque
  • drawing with rectangle: it's not opaque

alt text

What is going on here?

You can see the same also applies for other colors:

brush = new SolidBrush(0xFFff0000); //solid (i.e. non-opaque) red
graphics.FillRectangle(brush, x, y,    30, 30);
graphics.FillEllipse(brush,   x, y+33, 30, 30);

brush = new SolidBrush(0xFF00ff00); //solid (i.e. non-opaque) green
graphics.FillRectangle(brush, x, y,    30, 30);
graphics.FillEllipse(brush,   x, y+33, 30, 30);

brush = new SolidBrush(0xFF0000ff); //solid (i.e. non-opaque) blue
graphics.FillRectangle(brush, x, y,    30, 30);
graphics.FillEllipse(brush,   x, y+33, 30, 30);

brush = new SolidBrush(0xFFffffff); //solid (i.e. non-opaque) white
graphics.FillRectangle(brush, x, y,    30, 30);
graphics.FillEllipse(brush,   x, y+33, 30, 30);

alt text

Conclusion: Why does:

  • FillEllipse with an opaque color draw opaque
  • FillRectangle with an opaque color draws partially transparent

Note: This question is very nearly a duplicate of my other question.
Except this question focuses on the
difference between FillRectangle and
FillEllipse - whereas that question
deals with *How to draw opaque colors
on glass.

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文