JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
15.87k stars 1.15k forks source link

Converting color from `CieLab` colorspace to `Srgb` differs between 1.3.1 and 1.4.0 #3163

Closed haluzpav closed 1 year ago

haluzpav commented 1 year ago

Describe the bug

I'm auto-generating some colors in CieLab color space, and noticed they look different after upgrading id("org.jetbrains.compose") version "1.3.1" to 1.4.0. I discovered that the problem is probably in converting from CieLab to Srgb.

Affected platforms Select one of the platforms below:

Versions

To Reproduce

Here's an example, showing the inconsistency. Notice the difference in the last lines of the output.

Source scratch file:

import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.colorspace.ColorSpaces

Color(0, 180, 0)
Color(0, 180, 0).convert(ColorSpaces.CieLab)
Color(63.9375f, -61.03125f, 62.34375f, colorSpace = ColorSpaces.CieLab)
Color(63.9375f, -61.03125f, 62.34375f, colorSpace = ColorSpaces.CieLab).convert(ColorSpaces.Srgb)

Output with 1.3.1:

Color(0.0, 0.7058824, 0.0, 1.0, sRGB IEC61966-2.1)
Color(63.9375, -61.03125, 62.34375, 1.0, Generic L*a*b*)
Color(63.9375, -61.03125, 62.34375, 1.0, Generic L*a*b*)
Color(0.0, 0.7058824, 0.0, 1.0, sRGB IEC61966-2.1)  // matches the first line, OK

Output with 1.4.0:

Color(0.0, 0.7058824, 0.0, 1.0, sRGB IEC61966-2.1)
Color(63.9375, -61.03125, 62.34375, 1.0, Generic L*a*b*)
Color(63.9375, -61.03125, 62.34375, 1.0, Generic L*a*b*)
Color(1.0, 0.37254903, 0.17254902, 1.0, sRGB IEC61966-2.1) // different than 1.3.1, and also the first line, wut?
haluzpav commented 1 year ago

I somehow missed your issue template when I had to log in, sorry. Adjusted the report.

igordmn commented 1 year ago

Thanks!

Reproducible also on Windows and on Android. Created an issue in the Jetpack Compose tracker. Follow it there.

okushnikov commented 1 month ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.