Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from godaddy/feature/remove-dependency-on-expe…
Browse files Browse the repository at this point in the history
…rimental

Remove @ExperimentalGraphicsApi usage
Rebecca Franks authored Jan 5, 2022
2 parents 63854e8 + f246ce1 commit 7da1762
Showing 5 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion color-picker/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -98,7 +98,7 @@ publishing {
publications.withType(MavenPublication::class) {
groupId = "com.godaddy.android.colorpicker"
artifactId = "compose-color-picker"
version = "0.3.0"
version = "0.3.1"

artifact(tasks["javadocJar"])

Original file line number Diff line number Diff line change
@@ -30,7 +30,6 @@ import kotlin.math.floor
* @param currentColor the initial color to set on the alpha bar.
* @param onAlphaChanged the callback that is invoked when alpha value changes. 0 - 1.
*/
@ExperimentalGraphicsApi
@Composable
internal fun AlphaBar(
modifier: Modifier = Modifier,
Original file line number Diff line number Diff line change
@@ -25,7 +25,6 @@ import androidx.compose.ui.unit.dp
* @param onColorChanged callback that is triggered when the color changes
*
*/
@ExperimentalGraphicsApi
@Composable
fun ClassicColorPicker(
modifier: Modifier = Modifier,
Original file line number Diff line number Diff line change
@@ -29,9 +29,10 @@ data class HsvColor(
val alpha: Float
) {

@ExperimentalGraphicsApi
fun toColor(): Color {
return Color.hsv(hue, saturation, value, alpha)
val hsv = HSV(hue, saturation, value, alpha)
val rgb = hsv.toSRGB()
return Color(rgb.redInt, rgb.greenInt, rgb.blueInt, rgb.alphaInt)
}


Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@ import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.unit.IntSize
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.toSize
import com.github.ajalt.colormath.model.HSV

/**
* Saturation Value area Component that invokes onSaturationValueChanged when the saturation or value is mutated.
@@ -30,7 +31,6 @@ import androidx.compose.ui.unit.toSize
* @param onSaturationValueChanged the callback that is invoked when saturation or value component of the changes.
* saturation, value both between 0 - 1.
*/
@ExperimentalGraphicsApi
@Composable
internal fun SaturationValueArea(
modifier: Modifier = Modifier,
@@ -42,10 +42,12 @@ internal fun SaturationValueArea(
}

val currentColorGradientBrush = remember(currentColor.hue) {
val hsv = HSV(currentColor.hue, 1.0f, 1.0f)
val rgb = hsv.toSRGB()
Brush.horizontalGradient(
listOf(
Color(0xffffffff),
Color.hsv(currentColor.hue, 1.0f, 1.0f)
Color(rgb.redInt, rgb.greenInt, rgb.blueInt, rgb.alphaInt)
)
)
}

0 comments on commit 7da1762

Please sign in to comment.