Skip to content

HsvColorPicker.wheelImageBitmap isn't updating properly #124

@nsuriadi

Description

@nsuriadi

Please complete the following information:

  • Library Version: 1.1.2
  • Affected Device(s): Tested on Pixel 7 & Emulator

Describe the Bug:

  • I'm using a custom ImageBitmap to render the wheel on the color picker
  • I'd like to update the wheel color every time a new color is selected on HsvColorPicker
  • HsvColorPicker is still re-using the initial ImageBitmap

Note: BrightnessSlider.wheelImageBitmap doesn't seem to have the same issue. This can also be worked around by using HsvColorPicker.drawOnPosSelected, so mainly wanted to raise and verify if this is an issue that'd be worth fixing

val controller = rememberColorPickerController()
Column {
  HsvColorPicker(
    modifier = Modifier.height(280.dp),
    controller = controller,
    wheelImageBitmap = createWheelImageBitmap(
      offset = controller.selectedPoint.value,
      color = controller.selectedColor.value,
    ), // the image isn't being updated
  )
}
fun createWheelBitmap(
  offset: Offset,
  color: Color,
) = ImageBitmap(
  width = 75,
  height = 75,
  config = ImageBitmapConfig.Argb8888,
).also { 
  with(Canvas(it)) {
    drawCircle(
      center = offset,
      radius = 75 / 2f,
      paint = Paint().apply {
        style = PaintingStyle.Fill
        color = color,
      },
    )
  }
}

Expected Behavior:

  • HsvColorPicker updates wheelImageBitmap when color is changed

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions