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

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

    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.)

    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.

提交回复
热议问题