隨機顏色生成
隨機生成顏色
/* *隨機顏色(十六進制代碼) */ function randomHexColor() { var seed = Math.random(), result = seed.toString(16).substr(2, 6); while (result.length < 6) { result += '0' } return '#' + result; } /* *隨機顏色(RGB值) */ function randomRgbColor() { var rgb = [ Math.floor(Math.random() * 255 + 1) , Math.floor(Math.random() * 255 + 1) , Math.floor(Math.random() * 255 + 1) ]; return 'rgb(' + rgb.join(',') + ')'; }
浙公網安備 33010602011771號