@@ -38,13 +38,14 @@ import androidx.compose.ui.platform.LocalHapticFeedback
3838import androidx.compose.ui.unit.Dp
3939import androidx.compose.ui.unit.dp
4040import com.mocharealm.gaze.capsule.ContinuousCapsule
41- import top.yukonga.miuix.kmp.utils.ColorUtils
42- import top.yukonga.miuix.kmp.utils.Hsv
43- import top.yukonga.miuix.kmp.utils.OkLab
44- import top.yukonga.miuix.kmp.utils.OkLch
45- import top.yukonga.miuix.kmp.utils.toHsv
46- import top.yukonga.miuix.kmp.utils.toOkLab
47- import top.yukonga.miuix.kmp.utils.toOkLch
41+ import top.yukonga.miuix.kmp.color.api.toHsv
42+ import top.yukonga.miuix.kmp.color.api.toOkLab
43+ import top.yukonga.miuix.kmp.color.api.toOkLch
44+ import top.yukonga.miuix.kmp.color.core.Transforms
45+ import top.yukonga.miuix.kmp.color.space.Hsv
46+ import top.yukonga.miuix.kmp.color.space.OkHsv
47+ import top.yukonga.miuix.kmp.color.space.OkLab
48+ import top.yukonga.miuix.kmp.color.space.OkLch
4849import kotlin.math.ceil
4950import kotlin.math.min
5051
@@ -221,7 +222,7 @@ fun HsvHueSlider(
221222 hapticEffect : SliderDefaults .SliderHapticEffect = SliderDefaults .DefaultHapticEffect
222223) {
223224 val hsvHueColors = remember {
224- ColorUtils .generateHsvHueColors()
225+ Transforms .generateHsvHueColors()
225226 }
226227
227228 ColorSlider (
@@ -353,12 +354,16 @@ fun OkHsvColorPicker(
353354 var currentAlpha by remember { mutableStateOf(1f ) }
354355
355356 val selectedColor = remember(currentH, currentS, currentV, currentAlpha) {
356- ColorUtils .okhsvToColor(currentH, currentS, currentV, currentAlpha)
357+ OkHsv (
358+ h = currentH,
359+ s = currentS,
360+ v = currentV
361+ ).toColor(currentAlpha)
357362 }
358363
359364 LaunchedEffect (initialColor) {
360365 if (initialSetup) {
361- val okhsv = ColorUtils .colorToOkhsv(initialColor)
366+ val okhsv = Transforms .colorToOkhsv(initialColor)
362367 currentH = okhsv[0 ]
363368 currentS = okhsv[1 ]
364369 currentV = okhsv[2 ]
@@ -438,7 +443,7 @@ fun OkHsvHueSlider(
438443 hapticEffect : SliderDefaults .SliderHapticEffect = SliderDefaults .DefaultHapticEffect
439444) {
440445 val okHsvHueColors = remember {
441- ColorUtils .generateOkHsvHueColors()
446+ Transforms .generateOkHsvHueColors()
442447 }
443448
444449 ColorSlider (
@@ -467,8 +472,8 @@ fun OkHsvSaturationSlider(
467472) {
468473 val saturationColors = remember(currentH) {
469474 listOf (
470- ColorUtils .okhsvToColor(currentH, 0f , 1f , 1f ),
471- ColorUtils .okhsvToColor(currentH, 1f , 1f , 1f )
475+ Transforms .okhsvToColor(currentH, 0f , 1f , 1f ),
476+ Transforms .okhsvToColor(currentH, 1f , 1f , 1f )
472477 )
473478 }
474479
@@ -500,8 +505,8 @@ fun OkHsvValueSlider(
500505) {
501506 val valueColors = remember(currentH, currentS) {
502507 listOf (
503- ColorUtils .okhsvToColor(currentH, currentS, 0f , 1f ),
504- ColorUtils .okhsvToColor(currentH, currentS, 1f , 1f )
508+ Transforms .okhsvToColor(currentH, currentS, 0f , 1f ),
509+ Transforms .okhsvToColor(currentH, currentS, 1f , 1f )
505510 )
506511 }
507512
@@ -534,7 +539,7 @@ fun OkHsvAlphaSlider(
534539 hapticEffect : SliderDefaults .SliderHapticEffect = SliderDefaults .DefaultHapticEffect
535540) {
536541 val alphaColors = remember(currentH, currentS, currentV) {
537- val baseColor = ColorUtils .okhsvToColor(currentH, currentS, currentV)
542+ val baseColor = Transforms .okhsvToColor(currentH, currentS, currentV)
538543 listOf (baseColor.copy(alpha = 0f ), baseColor.copy(alpha = 1f ))
539544 }
540545
@@ -761,8 +766,8 @@ fun OkLchLightnessSlider(
761766 val cInternal = currentC * 0.4f
762767 val colors = remember(currentC, currentH) {
763768 listOf (
764- ColorUtils .oklchToColor(0f , cInternal, hDeg, 1f ),
765- ColorUtils .oklchToColor(1f , cInternal, hDeg, 1f )
769+ Transforms .oklchToColor(0f , cInternal, hDeg, 1f ),
770+ Transforms .oklchToColor(1f , cInternal, hDeg, 1f )
766771 )
767772 }
768773
@@ -786,8 +791,8 @@ fun OkLchChromaSlider(
786791 val hDeg = currentH * 360f
787792 val colors = remember(currentL, currentH) {
788793 listOf (
789- ColorUtils .oklchToColor(currentL, 0f , hDeg, 1f ),
790- ColorUtils .oklchToColor(currentL, 0.4f , hDeg, 1f )
794+ Transforms .oklchToColor(currentL, 0f , hDeg, 1f ),
795+ Transforms .oklchToColor(currentL, 0.4f , hDeg, 1f )
791796 )
792797 }
793798
@@ -809,7 +814,7 @@ fun OkLchHueSlider(
809814 hapticEffect : SliderDefaults .SliderHapticEffect = SliderDefaults .DefaultHapticEffect
810815) {
811816 val colors = remember(currentL, currentC) {
812- ColorUtils .generateOkLchHueColors(currentL, currentC)
817+ Transforms .generateOkLchHueColors(currentL, currentC)
813818 }
814819
815820 ColorSlider (
@@ -833,7 +838,7 @@ fun OkLchAlphaSlider(
833838 val hDeg = currentH * 360f
834839 val cInternal = currentC * 0.4f
835840 val colors = remember(currentL, currentC, currentH) {
836- val opaque = ColorUtils .oklchToColor(currentL, cInternal, hDeg, 1f )
841+ val opaque = Transforms .oklchToColor(currentL, cInternal, hDeg, 1f )
837842 val transparent = Color (opaque.red, opaque.green, opaque.blue, 0f )
838843 listOf (transparent, opaque)
839844 }
0 commit comments