[2
颜色在设计,品牌和UX中至关重要。 选择合适的颜色对于任何产品或网站都至关重要,但是导航无数的阴影和色调可能具有挑战性。本文详细介绍了利用欧几里得距离的颜色匹配库的创建。
[2
此库简化了开发人员的颜色匹配,提供了几个关键功能:
hex-to-rgb转换:
将十六进制代码转换为更通用的RGB格式。颜色匹配:标识给定调色板中最接近的颜色匹配。
使用Euclidean距离来测量两种颜色之间的差异。
精确的匹配检测:const {colorname,extcrectMatch,closeSthex} = sideencolor(“#dd4c22”); console.log(colorname); //输出:“生动的橙色” console.log(ecractMatch); //输出:true(如果完全匹配) console.log(clessEsthex); //输出:“#dd4c22”(最近的十六进制代码)
实用程序函数将十六进制转换为rgb:
(rgb数组)
const rgb1 = [221,76,34]; const rgb2 = [255,255,255]; const距离=计算抑制(RGB1,RGB2); console.log(距离); //输出:代表距离的数字值
const {sigensColor} = require(“@iamsuz/color-kit”); const {colorRANM,coldesthex,extercMatch} = sideencolor(“#dd4c22”); console.log(colorname); //“生动的橙色” console.log(ecractMatch); // 真的 console.log(clessEsthex); //“#dd4c22”
此库提供了打字稿支持。
免责声明: 提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发到邮箱:[email protected] 我们会第一时间内为您处理。
Copyright© 2022 湘ICP备2022001581号-3