summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaewoong Eum <skydoves2@gmail.com>2026-09-16 12:30:46 +0300
committerGitHub <noreply@github.com>2026-09-16 12:30:46 +0300
commita756e7c8d213579de61b905d54aa53f1e1c83a2e (patch)
treec2415fcbedb18af2a892ae34267956e8e7a24e94
parent21da5bfdb5e147be6e335d0ad38d1b0111562dab (diff)
parent025b0b3c7a510a784bb2f2a9c11ac85381004e31 (diff)
downloadcolorpicker-compose-a756e7c8d213579de61b905d54aa53f1e1c83a2e.tar.xz
Merge pull request #192 from iprashantpanwar/fix/stale-controller-api-docs
Fix stale ColorPickerController API examples in README and docs site
-rw-r--r--README.md21
-rw-r--r--docs/src/wasmJsMain/kotlin/docs/screen/ApiControllerScreen.kt8
-rw-r--r--docs/src/wasmJsMain/kotlin/docs/screen/ApiHsvColorPickerScreen.kt4
-rw-r--r--docs/src/wasmJsMain/kotlin/docs/screen/ApiImageColorPickerScreen.kt12
4 files changed, 26 insertions, 19 deletions
diff --git a/README.md b/README.md
index e7bac02..5b50437 100644
--- a/README.md
+++ b/README.md
@@ -134,11 +134,16 @@ As you can see the above, you can set the palette with the `setPaletteImageBitma
#### PaletteContentScale
-You can adjust your palette's image scale with the `setPaletteContentScale` function of the controller as the below:
+You can adjust your palette's image scale with the `paletteContentScale` parameter of `ImageColorPicker` as the below:
```kotlin
-controller.setPaletteContentScale(PaletteContentScale.FIT) // scale the image to fit width and height.
-controller.setPaletteContentScale(PaletteContentScale.CROP) // center crop the image.
+ImageColorPicker(
+ modifier = Modifier.fillMaxSize(),
+ controller = controller,
+ paletteImageBitmap = ImageBitmap.imageResource(R.drawable.palettebar),
+ paletteContentScale = PaletteContentScale.FIT, // scale the image to fit width and height.
+ // paletteContentScale = PaletteContentScale.CROP, // center crop the image.
+)
```
<img src="preview/preview2.gif" width="270" align="right">
@@ -165,7 +170,7 @@ HsvColorPicker(
To initialize the color picker with a specific color, pass the color to the `initialColor` argument. Initial color is white by default.
-> **Note**: If you use `HsvColorPicker`, you can not set the palette and content scale with the `setPaletteImageBitmap` and `setPaletteContentScale` functions.
+> **Note**: `HsvColorPicker` draws its own palette, so `setPaletteImageBitmap` on the controller and the `paletteContentScale` parameter are for `ImageColorPicker` only.
The `onStart` / `onFinish` callbacks are also available on `ImageColorPicker`, `AlphaSlider`, `BrightnessSlider`, `HueSlider`, and `SaturationSlider`. Use them to bracket gesture-driven work — for example to show a press indicator, snapshot state when the gesture begins, or commit/throttle work when it ends.
@@ -223,10 +228,10 @@ onColorChanged = { envelope ->
You can customize the wheel with the following functions:
```kotlin
-.setWheelRadius(40.dp) // set the radius size of the wheel.
-.setWheelColor(Color.Blue) // set the color of the wheel.
-.setWheelAlpha(0.5f) // set the transparency of the wheel.
-.setWheelImageBitmap(imageBitmap) // set the wheel image with your custom ImageBitmap.
+controller.wheelRadius = 40.dp // set the radius size of the wheel.
+controller.wheelColor = Color.Blue // set the color of the wheel.
+controller.wheelAlpha = 0.5f // set the transparency of the wheel.
+controller.wheelBitmap = imageBitmap // set the wheel image with your custom ImageBitmap.
```
#### Select Points
diff --git a/docs/src/wasmJsMain/kotlin/docs/screen/ApiControllerScreen.kt b/docs/src/wasmJsMain/kotlin/docs/screen/ApiControllerScreen.kt
index 60ee84c..9e4ce24 100644
--- a/docs/src/wasmJsMain/kotlin/docs/screen/ApiControllerScreen.kt
+++ b/docs/src/wasmJsMain/kotlin/docs/screen/ApiControllerScreen.kt
@@ -127,10 +127,10 @@ fun ApiControllerScreen() {
Spacer(modifier = Modifier.height(16.dp))
CodeBlock(
- code = """controller.setWheelRadius(40.dp)
-controller.setWheelColor(Color.Blue)
-controller.setWheelAlpha(0.5f)
-controller.setWheelImageBitmap(imageBitmap)""",
+ code = """controller.wheelRadius = 40.dp
+controller.wheelColor = Color.Blue
+controller.wheelAlpha = 0.5f
+controller.wheelBitmap = imageBitmap""",
)
Spacer(modifier = Modifier.height(32.dp))
diff --git a/docs/src/wasmJsMain/kotlin/docs/screen/ApiHsvColorPickerScreen.kt b/docs/src/wasmJsMain/kotlin/docs/screen/ApiHsvColorPickerScreen.kt
index 3b02026..4782975 100644
--- a/docs/src/wasmJsMain/kotlin/docs/screen/ApiHsvColorPickerScreen.kt
+++ b/docs/src/wasmJsMain/kotlin/docs/screen/ApiHsvColorPickerScreen.kt
@@ -161,8 +161,8 @@ fun ApiHsvColorPickerScreen() {
Spacer(modifier = Modifier.height(32.dp))
Callout(
- text = "Note: When using HsvColorPicker, you cannot use setPaletteImageBitmap() " +
- "or setPaletteContentScale() functions on the controller.",
+ text = "Note: HsvColorPicker draws its own palette, so setPaletteImageBitmap() on the " +
+ "controller and the paletteContentScale parameter are for ImageColorPicker only.",
type = CalloutType.Warning,
)
diff --git a/docs/src/wasmJsMain/kotlin/docs/screen/ApiImageColorPickerScreen.kt b/docs/src/wasmJsMain/kotlin/docs/screen/ApiImageColorPickerScreen.kt
index 5389105..1b0123c 100644
--- a/docs/src/wasmJsMain/kotlin/docs/screen/ApiImageColorPickerScreen.kt
+++ b/docs/src/wasmJsMain/kotlin/docs/screen/ApiImageColorPickerScreen.kt
@@ -145,11 +145,13 @@ fun ApiImageColorPickerScreen() {
Spacer(modifier = Modifier.height(16.dp))
CodeBlock(
- code = """// Scale to fit within bounds
-controller.setPaletteContentScale(PaletteContentScale.FIT)
-
-// Center crop the image
-controller.setPaletteContentScale(PaletteContentScale.CROP)""",
+ code = """ImageColorPicker(
+ modifier = Modifier.fillMaxSize(),
+ controller = controller,
+ paletteImageBitmap = paletteImageBitmap,
+ paletteContentScale = PaletteContentScale.FIT, // scale to fit within bounds
+ // paletteContentScale = PaletteContentScale.CROP, // center crop the image
+)""",
)
Spacer(modifier = Modifier.height(32.dp))