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

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

    Assuming you get the color as RGB, first convert it to HSV (hue, saturation, value) color space. Then increase/decrease the value to produce lighter/darker shade of the color. Then convert back to RGB.

提交回复
热议问题