* Get the color as a string * @param {boolean} alpha Whether to include alpha channel * @returns
(alpha)
| 17 | * @returns |
| 18 | */ |
| 19 | toString(alpha) { |
| 20 | const rgb = () => `rgb(${this.r}, ${this.g}, ${this.b})`; |
| 21 | const rgba = () => `rgba(${this.r}, ${this.g}, ${this.b}, ${this.a})`; |
| 22 | if (alpha === undefined) { |
| 23 | return this.a === 1 ? rgb() : rgba(); |
| 24 | } |
| 25 | return alpha ? rgba() : rgb(); |
| 26 | } |
| 27 | } |