hsv/hsb转rgb颜色
//h:[0,360],s:[0,100],v:[0,100] //return r:[0,256], g:[0,256],b:[0,256] function hsvtorgb(h, s, v) { s = s / 100; v = v / 100; var h1 = Math.floor(h / 60) % 6; var f = h / 60 - h1; var p = v * (1 - s); var q = v * (1 - f * s); var t = v * (1 - (1 - f) * s); var r, g, b; switch (h1) { case 0: r = v; g = t; b = p; break; case 1: r = q; g = v; b = p; break; case 2: r = p; g = v; b = t; break; case 3: r = p; g = q; b = v; break; case 4: r = t; g = p; b = v; break; case 5: r = v; g = p; b = q; break; } return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)]; }
uuid
function uuid() { function S4() { return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1) } return (S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4()); }
金额小写转大写
function changeMoneyToChinese(num: number) { if (num == 0) { return "零" } let numString = num.toString() if (!/^(0|[1-9]d*)(.d+)?$/.test(numString)) return "数据非法"; let unit = "仟佰拾亿仟佰拾万仟佰拾元角分", str = ""; numString += "00"; let pointIndex = numString.indexOf('.'); if (pointIndex >= 0) numString = numString.substring(0, pointIndex) + numString.substr(pointIndex + 1, 2); unit = unit.substr(unit.length - numString.length); for (var i = 0; i < numString.length; i++){ str += '零壹贰叁肆伍陆柒捌玖'.charAt(Number(numString.charAt(i))) + unit.charAt(i); } return str.replace(/零(仟|佰|拾|角)/g, "零") .replace(/(零)+/g, "零") .replace(/零(万|亿|元)/g, "$1") .replace(/(亿)万|壹(拾)/g, "$1$2") .replace(/^元零?|零分/g, "") .replace(/元$/g, "元整"); }