Search code examples
javascriptjquerycolors

How to get random color based on hex color from dark to light by JS?


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


Solution

  • 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