十六进制彩色反相器
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了十六进制彩色反相器相关的知识,希望对你有一定的参考价值。
By Matt Lagrandeur
function invertHex(hexnum){ if(hexnum.length != 6) { alert("Hex color must be six hex numbers in length."); return false; } hexnum = hexnum.toUpperCase(); var splitnum = hexnum.split(""); var resultnum = ""; var simplenum = "FEDCBA9876".split(""); var complexnum = new Array(); complexnum.A = "5"; complexnum.B = "4"; complexnum.C = "3"; complexnum.D = "2"; complexnum.E = "1"; complexnum.F = "0"; for(i=0; i<6; i++){ if(!isNaN(splitnum[i])) { resultnum += simplenum[splitnum[i]]; } else if(complexnum[splitnum[i]]){ resultnum += complexnum[splitnum[i]]; } else { alert("Hex colors must only include hex numbers 0-9, and A-F"); return false; } } return resultnum; }
以上是关于十六进制彩色反相器的主要内容,如果未能解决你的问题,请参考以下文章