* Converts a HSL color to HSB. * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_HSV. * * @returns An HSBColor object.
()
| 701 | * @returns An HSBColor object. |
| 702 | */ |
| 703 | private toHSB(): IColor { |
| 704 | let saturation = this.saturation / 100; |
| 705 | let lightness = this.lightness / 100; |
| 706 | let brightness = lightness + saturation * Math.min(lightness, 1 - lightness); |
| 707 | saturation = brightness === 0 ? 0 : 2 * (1 - lightness / brightness); |
| 708 | return new HSBColor( |
| 709 | toFixedNumber(this.hue, 2), |
| 710 | toFixedNumber(saturation * 100, 2), |
| 711 | toFixedNumber(brightness * 100, 2), |
| 712 | this.alpha |
| 713 | ); |
| 714 | } |
| 715 | |
| 716 | /** |
| 717 | * Converts a HSL color to RGB. Conversion formula adapted from |
no test coverage detected