* @function LevelRenderer.Tool.Color.prototype.toArray * @description 颜色字符串转换为rgba数组。 * @param {string} color - 颜色。 * @returns {Array. } 颜色值数组。
(color)
| 443 | * @returns {Array.<number>} 颜色值数组。 |
| 444 | */ |
| 445 | toArray(color) { |
| 446 | color = this.trim(color); |
| 447 | if (color.indexOf('rgba') < 0) { |
| 448 | color = this.toRGBA(color); |
| 449 | } |
| 450 | |
| 451 | var data = []; |
| 452 | var i = 0; |
| 453 | color.replace(/[\d.]+/g, function (n) { |
| 454 | if (i < 3) { |
| 455 | n = n | 0; |
| 456 | } else { |
| 457 | // Alpha |
| 458 | n = +n; |
| 459 | } |
| 460 | data[i++] = n; |
| 461 | }); |
| 462 | return data; |
| 463 | } |
| 464 | |
| 465 | /** |
| 466 | * @function LevelRenderer.Tool.Color.prototype.convert |
no test coverage detected