How do I determine darker or lighter color variant of a given color?

前端 未结 13 676
情话喂你
情话喂你 2020-12-04 07:37

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 effe

13条回答
  •  半阙折子戏
    2020-12-04 08:12

    If you are using RGB colors I would transform this color paramaters to HSL (hue, saturation, lightness), modify the lightness parameter and then transform back to RGB. Google around and you'll find a lot of code samples on how to do these color representation transformations (RGB to HSL and viceversa).

    This is what I quickly found: http://bytes.com/forum/thread250450.html

提交回复
热议问题