Skip to content

Commit

Permalink
Merge pull request #54 from darktiny/fix_alpha
Browse files Browse the repository at this point in the history
Fix selectByColor not updating alpha
  • Loading branch information
skydoves authored May 8, 2024
2 parents 7112a71 + 31a0220 commit e33f505
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions colorpicker-compose/api/colorpicker-compose.api
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public final class com/github/skydoves/colorpicker/compose/ColorPickerController
public final fun selectByColor-DxMtmZc (JZ)V
public final fun selectByCoordinate (FFZ)V
public final fun selectCenter (Z)V
public final fun setAlpha (FZ)V
public final fun setBrightness (FZ)V
public final fun setDebounceDuration (J)V
public final fun setEnabled (Z)V
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ public class ColorPickerController {
val y = saturationVector * sin(angle) + (palette.height / 2)
selectByCoordinate(x.toFloat(), y.toFloat(), fromUser)

setAlpha(color.alpha, fromUser = false)

val brightness = max(max(color.red, color.green), color.blue)
setBrightness(brightness, fromUser = false)
}
Expand Down Expand Up @@ -270,7 +272,7 @@ public class ColorPickerController {
}

/** Combine the alpha value to the selected pure color. */
internal fun setAlpha(alpha: Float, fromUser: Boolean) {
public fun setAlpha(alpha: Float, fromUser: Boolean) {
this.alpha.value = alpha
_selectedColor.value = selectedColor.value.copy(alpha = alpha)
notifyColorChanged(fromUser)
Expand Down

0 comments on commit e33f505

Please sign in to comment.