gpt4 book ai didi

javascript - 通过 HEX 或 RGB 获取颜色名称

转载 作者:数据小太阳 更新时间:2023-10-29 03:53:11 24 4
gpt4 key购买 nike

如何在知道代码 RBG/HEX 的情况下使用 JS/JQuery 获取颜色名称?

例如:

Colorname      RGB
black #000000
white #FFFFFF
red #FF0000
green #008000

最佳答案

您可以使用Name that Color .

示例:

let result = ntc.name('#6195ed');

let rgb_value = result[0]; // #6495ed : RGB value of closest match
let specific_name = result[1]; // Cornflower Blue : Color name of closest match
let is_exact_match = result[2]; // false : True if exact color match

还有一个包含额外参数的 Name that Color 的变体:

http://www.color-blindness.com/color-name-hue-tool/js/ntc.js

示例:

let result = ntc.name('#6195ed');

let rgb_value = result[0]; // #6495ed : RGB value of closest match
let specific_name = result[1]; // Cornflower Blue : Color name of closest match
let shade_value = result[2]; // #0000ff : RGB value of shade of closest match
let shade_name = result[3]; // Blue : Color name of shade of closest match
let is_exact_match = result[4]; // false : True if exact color match

关于javascript - 通过 HEX 或 RGB 获取颜色名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9224404/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com