简体   繁体   English

C#如何使图形绘制的重叠区域更暗

[英]C# How to make overlapping areas drawn with graphics darker

I am working on a small project that draws many filled circles on a form with the Graphics class and SolidBrushes. 我正在做一个小项目,该项目使用Graphics类和SolidBrushes在表单上绘制许多填充的圆。 Is there a way to make areas darker when graphics are overlapping? 当图形重叠时,是否有办法使区域变暗? I would like to have it so as more circles overlap, the overlapped areas get gradually darker in whatever color the circles are drawn in. 我希望这样,以便有更多的圆圈重叠,无论以何种颜色绘制圆圈,重叠的区域都会逐渐变暗。

I have looked over the Graphics class documentation but I can't seem to find anything talking about this in it...but I might have missed something. 我查看了Graphics类文档,但似乎找不到有关此的任何信息……但是我可能错过了一些东西。

Any help is greatly appreciated! 任何帮助是极大的赞赏! Thank you! 谢谢!

You have a couple of options, when a shape is transparent you will get the behavior you need. 您有两个选择,当形状透明时,您将获得所需的行为。

a) Set opacity less than 1 a)设置不透明度小于1

<Ellipse Height="10" Width="10" Fill="#101010" Opacity="0.5"></Ellipse>

b) Use alpha colors to fill your shapes. b)使用Alpha颜色填充您的形状。

<Ellipse Height="10" Width="10" Fill="#50101010"></Ellipse>

Notice the Fill property of b) includes "alpha", that indicates opacity, 请注意,b)的Fill属性包含“ alpha”,表示不透明度,

#50(alpha)10(Red)10(green)10(blue)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM