如何确定一个给定的颜色较暗或较亮的颜色变? [英] How do I determine darker or lighter color variant of a given color?

查看:339
本文介绍了如何确定一个给定的颜色较暗或较亮的颜色变?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于系统或用户的任何色调的源颜色,我想一个简单的算法,我可以用它来制定出所选颜色的亮或更暗的变种。类似于在Windows Live Messenger的被用来定义用户界面效果。

Given a source color of any hue by the system or user, I'd like a simple algorithm I can use to work out a lighter or darker variants of the selected color. Similar to effects used on Windows Live Messenger for styling the user interface.

语言是C#使用.NET 3.5。

Language is C# with .net 3.5.

回应评论:颜色格式(阿尔法)RGB。随着值字节或浮动。

Responding to comment: Color format is (Alpha)RGB. With values as bytes or floats.

标记的回答:对于我使用的情况下(一些简单的UI效果),我标记为接受的答案其实是最简单的此上下文。不过,我已经放弃了投票的更复杂,更准确的答案了。任何人这样做更先进的彩色业务和发现这个线程在未来一定要检查这些了。太感谢。 :)

Marking answer: For the context of my use (a few simple UI effects), the answer I'm marking as accepted is actually the most simple for this context. However, I've given up votes to the more complex and accurate answers too. Anyone doing more advanced color operations and finding this thread in future should definitely check those out. Thanks SO. :)

推荐答案

仅仅通过你想要修改的水平量乘以RGB值。如果颜色之一,已经在最大值,那么你可以不是任何亮(HSV使用数学反正。)使

Simply multiply the RGB values by the amount you want to modify the level by. If one of the colors is already at the max value, then you can't make it any brighter (using HSV math anyway.)

这给少了很多数学作为切换到HSV然后修改五,这给了相同的结果转换为HSL,然后修改L,只要你不想开始失去饱和完全相同的结果。

This gives the exact same result with a lot less math as switching to HSV and then modifying V. This gives the same result as switching to HSL and then modifying L, as long as you don't want to start losing saturation.

这篇关于如何确定一个给定的颜色较暗或较亮的颜色变?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆