算法解析成十六进制颜色系列 [英] Algorithm for parsing hex into color family

查看:297
本文介绍了算法解析成十六进制颜色系列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一个算法的存在,将输入颜色的十六进制值,输出什么颜色家族值属于?例如,如果我输入3333FF它会识别为是蓝色的阴影。我需要能够输入任意的十六进制值和缩小它的24颜色之一上的标准色轮加黑,白和灰色。 (我会考虑的黑色全灰值高达#151515,和白色所有值下降到#F1F1F1)

Does an algorithm exists that will input a color's hex value and output what color family that value belongs to? For example if i input 3333FF it would identify that as being a shade of blue. I would need to be able to input any hex value and narrow it down to one of the 24 colors on a standard color wheel plus black, white, and grey. (i would consider black all grey values up to #151515, and white all values down to #F1F1F1)

推荐答案

一会的方式是的十六进制代码转换为HSV ,然后分头行动色相值成区域。所以你刚才检查的色调,如果是这两个值之间是红色的,如果是这两者之间是黄色的,等你也可以检查饱和度和亮度,以确定什么叫白色,灰色和黑色。这些阈值将全部给你。

One way would be to convert the hex code to HSV and then split up the hue value into regions. So you just check the hue, if it's between these two values it's red, if it's between these it's yellow, etc. You can also check saturation and lightness to determine what to call white, grey, and black. Those thresholds will be all up to you.

这篇关于算法解析成十六进制颜色系列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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