2
我有字符串'rgb(255,0,0)'
並且需要獲取小數位數組。將rgb字符串轉換爲十進制
下面的代碼片段似乎給了我想要的結果。任何建議,關注,更好的方法?
var arrRGB = pagedefault.nodelist.style.color.match(/\d+/g); //gives me ["255","0","0"]
arrRGB[0] = Number(arrRGB[0])/255;
arrRGB[1] = Number(arrRGB[1])/255;
arrRGB[2] = Number(arrRGB[2])/255;