Returns this color expressed as a hex color code * @param {boolean} [useAlpha] - if alpha should be included in result * @return {string}
(useAlpha = true)
| 1046 | * @param {boolean} [useAlpha] - if alpha should be included in result |
| 1047 | * @return {string} */ |
| 1048 | toString(useAlpha = true) |
| 1049 | { |
| 1050 | if (debug && !this.isValid()) |
| 1051 | return '#000'; |
| 1052 | const toHex = (c)=> ((c=clamp(c)*255|0)<16 ? '0' : '') + c.toString(16); |
| 1053 | return '#' + toHex(this.r) + toHex(this.g) + toHex(this.b) + (useAlpha ? toHex(this.a) : ''); |
| 1054 | } |
| 1055 | |
| 1056 | /** Set this color from a hex code |
| 1057 | * @param {string} hex - html hex code |
no test coverage detected