(format: ColorFormat | 'css' = 'css')
| 664 | } |
| 665 | |
| 666 | toString(format: ColorFormat | 'css' = 'css') { |
| 667 | switch (format) { |
| 668 | case 'hex': |
| 669 | return this.toRGB().toString('hex'); |
| 670 | case 'hexa': |
| 671 | return this.toRGB().toString('hexa'); |
| 672 | case 'hsl': |
| 673 | return `hsl(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.lightness, 2)}%)`; |
| 674 | case 'css': |
| 675 | case 'hsla': |
| 676 | return `hsla(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.lightness, 2)}%, ${this.alpha})`; |
| 677 | default: |
| 678 | return this.toFormat(format).toString(format); |
| 679 | } |
| 680 | } |
| 681 | toFormat(format: ColorFormat): IColor { |
| 682 | switch (format) { |
| 683 | case 'hsl': |
nothing calls this directly
no test coverage detected