fun saturate()

in kotlin-css/src/commonMain/kotlin/kotlinx/css/Color.kt [297:308]


    fun saturate(percent: Int): Color {
        val isHSLA = value.startsWith("hsl", ignoreCase = true)
        val hsla = if (isHSLA) fromHSLANotation() else toRGBA().asHSLA()

        val saturation = hsla.saturation + (hsla.saturation * (normalizePercent(percent) / 100.0)).roundToInt()
        val newHSLa = hsla.copy(saturation = normalizePercent(saturation))
        return if (isHSLA) {
            hsl(newHSLa.hue, newHSLa.saturation, newHSLa.lightness, newHSLa.alpha)
        } else {
            with(newHSLa.asRGBA()) { rgb(red, green, blue, alpha) }
        }
    }