Home > Software engineering >  How to get random color based on hex color from dark to light by JS?
How to get random color based on hex color from dark to light by JS?

Time:03-11

I'm having a problem dynamically generating colors from dark to light which I'm going to use to create color differences on the pie chart. The color refers to one of the hex colors, for example #00695C to #00897B. How to get those colors by using javascript?

Example Image for Color Generate

CodePudding user response:

Instead of hex you can try hsl color in your project. Where you can reduce and increase intensity of l value between 0 and 100 to get different shades of light and dark. It's more straightforward

Refer this page for more details

https://www.w3schools.com/colors/colors_hsl.asp

CodePudding user response:

put all your favourite colours in an array, and then, map them.

  • Related