const Tools = {
constructor () {
},
/**
* [hexTransformationDecArray 十六進制顏色轉換成十進制數組]
* @param {[type]} color [description]
* @return {[type]} [description]
*/
hexTransformationDecArray (color) {
const array = []
if (Object.is(color.length, 4)) {
array.push(parseInt('0x' + color.slice(1, 2)))
array.push(parseInt('0x' + color.slice(2, 3)))
array.push(parseInt('0x' + color.slice(3, 4)))
} else if (Object.is(color.length, 7)) {
array.push(parseInt('0x' + color.slice(1, 3)))
array.push(parseInt('0x' + color.slice(3, 5)))
array.push(parseInt('0x' + color.slice(5, 7)))
} else {
array.push(255, 255, 255)
}
return array
}
}
exports.defalut = Tools
複製代碼