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

前端 未结 13 539
情话喂你
情话喂你 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:28

    You can convert your color into the HSL color-space, manipulate it there and convert back to your color-space of choice (most likely that's RGB)

    Lighter colors have a higher L-value, darker a lower.

    Here's the relevant stuff and all the equations:

    http://en.wikipedia.org/wiki/HSL_color_space

    Another method is to simply interpolate your color with white or black. This will also desaturate the color a bit but it's cheaper to calculate.

    0 讨论(0)
提交回复
热议问题