简体   繁体   English

如何通过JS获取基于十六进制颜色的随机颜色从深到浅?

[英]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.我在从暗到亮动态生成 colors 时遇到问题,我将使用它在饼图上创建颜色差异。 The color refers to one of the hex colors, for example #00695C to #00897B.颜色指的是十六进制 colors 之一,例如#00695C 到#00897B。 How to get those colors by using javascript?如何使用 javascript 获取那些 colors?

Example Image for Color Generate颜色生成的示例图像

put all your favourite colours in an array, and then, map them.将所有你喜欢的颜色放在一个数组中,然后是 map。

Instead of hex you can try hsl color in your project.您可以在项目中尝试 hsl 颜色而不是十六进制。 Where you can reduce and increase intensity of l value between 0 and 100 to get different shades of light and dark.您可以在 0 到 100 之间减少和增加l值的强度以获得不同的明暗度。 It's more straightforward它更直接

Refer this page for more details有关更多详细信息,请参阅此页面

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM