通过 HEX 或 RGB 获取颜色名称 [英] Get color name by HEX or RGB

查看:38
本文介绍了通过 HEX 或 RGB 获取颜色名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

知道代码 RBG/HEX,如何使用 JS/JQuery 获取颜色名称?

How can I get a color name using JS/JQuery, knowing the code RBG/HEX?

例如:

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

推荐答案

您可以使用 命名那个颜色.

示例:

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 也有一个变体,其中包含附加参数:


There is also a variation of Name that Color that includes additional parameters:

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

这篇关于通过 HEX 或 RGB 获取颜色名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆