Skip to content

Commit

Permalink
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
  • Loading branch information
Rebecca Franks authored Jan 5, 2022
2 parents 63854e8 + f246ce1 commit 7da1762
Show file tree
Hide file tree
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
Expand Up @@ -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"])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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,
Expand All @@ -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)
)
)
}
Expand Down

0 comments on commit 7da1762

Please sign in to comment.