将颜色着色一定百分比的 C# 算法

发布于 2024-07-27 22:42:05 字数 188 浏览 5 评论 0原文

我有一种颜色,我希望将该颜色的色调按一定百分比进行调整。 因此,100% 是颜色本身,90% 是稍浅的颜色,等等。基本上,如果颜色位于白色背景上,这就像为颜色添加 10% 的不透明度。 我需要将颜色转换为十六进制 HTML 颜色值,所以我不需要透明度。

是否有算法可以获取 System.Drawing.Color RGB 值的色调?

I have a color and I want get a tint of that color by a certain percent. So 100% is the color itself, 90% is a slightly lighter color, etc. Basically, it's like adding 10% of opacity to the color, if the color is on a white background. I need to convert the color into a hex HTML color value, so I don't want transparency.

Is there an algorithm to get a tint of the System.Drawing.Color RGB value?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

花开半夏魅人心 2024-08-03 22:42:11

是的,有很多不同的方法可以做到这一点。 一种方法是从 RGB 转换为 HSB(色调、饱和度、亮度),然后将亮度降低一定百分比。

Yep there are a lot of different ways to do this. One way would be to convert from RGB to HSB (Hue, Saturation, Brightness) and then crank the brightness down some percentage.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文