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