diff --git a/app/src/main/kotlin/com/github/skydoves/colorpickercomposedemo/MainScreen.kt b/app/src/main/kotlin/com/github/skydoves/colorpickercomposedemo/MainScreen.kt index 7124674..47fb585 100644 --- a/app/src/main/kotlin/com/github/skydoves/colorpickercomposedemo/MainScreen.kt +++ b/app/src/main/kotlin/com/github/skydoves/colorpickercomposedemo/MainScreen.kt @@ -70,7 +70,7 @@ fun MainScreen() { onColorChanged = { colorEnvelope: ColorEnvelope -> hexCode = colorEnvelope.hexCode textColor = colorEnvelope.color - } + }, ) Spacer(modifier = Modifier.height(50.dp)) @@ -81,7 +81,7 @@ fun MainScreen() { .padding(10.dp) .height(35.dp) .align(Alignment.CenterHorizontally), - controller = controller + controller = controller, ) BrightnessSlider( @@ -90,7 +90,7 @@ fun MainScreen() { .padding(10.dp) .height(35.dp) .align(Alignment.CenterHorizontally), - controller = controller + controller = controller, ) Spacer(modifier = Modifier.height(30.dp)) @@ -100,7 +100,7 @@ fun MainScreen() { color = textColor, fontSize = 16.sp, fontWeight = FontWeight.Bold, - modifier = Modifier.align(Alignment.CenterHorizontally) + modifier = Modifier.align(Alignment.CenterHorizontally), ) AlphaTile( @@ -108,7 +108,7 @@ fun MainScreen() { .size(80.dp) .clip(RoundedCornerShape(6.dp)) .align(Alignment.CenterHorizontally), - controller = controller + controller = controller, ) } } @@ -118,7 +118,7 @@ fun MainToolBar() { TopAppBar( elevation = 6.dp, backgroundColor = Color(0xFF6200EE), - modifier = Modifier.height(58.dp) + modifier = Modifier.height(58.dp), ) { Text( modifier = Modifier @@ -127,7 +127,7 @@ fun MainToolBar() { text = stringResource(R.string.app_name), color = Color.White, fontSize = 18.sp, - fontWeight = FontWeight.Bold + fontWeight = FontWeight.Bold, ) } } diff --git a/app/src/main/kotlin/com/github/skydoves/colorpickercomposedemo/PhotoPickerIcon.kt b/app/src/main/kotlin/com/github/skydoves/colorpickercomposedemo/PhotoPickerIcon.kt index 7dfe7b5..acd9a3d 100644 --- a/app/src/main/kotlin/com/github/skydoves/colorpickercomposedemo/PhotoPickerIcon.kt +++ b/app/src/main/kotlin/com/github/skydoves/colorpickercomposedemo/PhotoPickerIcon.kt @@ -41,7 +41,7 @@ import com.google.modernstorage.photopicker.PhotoPicker @Composable @SuppressLint("UnsafeOptInUsageError") fun ColumnScope.PhotoPickerIcon( - controller: ColorPickerController + controller: ColorPickerController, ) { val context = LocalContext.current val photoPicker = @@ -60,7 +60,7 @@ fun ColumnScope.PhotoPickerIcon( Box( modifier = Modifier .padding(horizontal = 16.dp) - .align(Alignment.End) + .align(Alignment.End), ) { Image( modifier = Modifier @@ -70,7 +70,7 @@ fun ColumnScope.PhotoPickerIcon( photoPicker.launch(PhotoPicker.Args(PhotoPicker.Type.IMAGES_ONLY, 1)) }, imageVector = ImageVector.vectorResource(R.drawable.ic_gallery), - contentDescription = null + contentDescription = null, ) } } diff --git a/buildSrc/src/main/kotlin/com/github/skydoves/colorpicker/compose/Dependencies.kt b/buildSrc/src/main/kotlin/com/github/skydoves/colorpicker/compose/Dependencies.kt index ba2c506..fd8464e 100644 --- a/buildSrc/src/main/kotlin/com/github/skydoves/colorpicker/compose/Dependencies.kt +++ b/buildSrc/src/main/kotlin/com/github/skydoves/colorpicker/compose/Dependencies.kt @@ -2,7 +2,7 @@ package com.github.skydoves.colorpicker.compose object Versions { internal const val ANDROID_GRADLE_PLUGIN = "7.4.2" - internal const val ANDROID_GRADLE_SPOTLESS = "6.7.0" + internal const val ANDROID_GRADLE_SPOTLESS = "6.19.0" internal const val GRADLE_NEXUS_PUBLISH_PLUGIN = "1.3.0" internal const val KOTLIN = "1.8.22" internal const val KOTLIN_GRADLE_DOKKA = "1.8.20" diff --git a/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/AlphaSlider.kt b/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/AlphaSlider.kt index 28b7ef0..2d6cf13 100644 --- a/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/AlphaSlider.kt +++ b/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/AlphaSlider.kt @@ -78,7 +78,7 @@ public fun AlphaSlider( }, tileOddColor: Color = defaultTileOddColor, tileEvenColor: Color = defaultTileEvenColor, - tileSize: Dp = 12.dp + tileSize: Dp = 12.dp, ) { val density = LocalDensity.current var backgroundBitmap: ImageBitmap? = null @@ -106,7 +106,7 @@ public fun AlphaSlider( val drawable = AlphaTileDrawable( with(density) { tileSize.toPx() }, tileOddColor, - tileEvenColor + tileEvenColor, ) backgroundBitmap ?.asAndroidBitmap() @@ -118,7 +118,7 @@ public fun AlphaSlider( 0, 0, backgroundCanvas.nativeCanvas.width, - backgroundCanvas.nativeCanvas.height + backgroundCanvas.nativeCanvas.height, ) drawable.draw(backgroundCanvas.nativeCanvas) backgroundCanvas.drawRoundRect( @@ -128,7 +128,7 @@ public fun AlphaSlider( bottom = size.height.toFloat(), radiusX = borderRadius.value, radiusY = borderRadius.value, - paint = borderPaint + paint = borderPaint, ) } bitmapSize = size @@ -139,13 +139,13 @@ public fun AlphaSlider( val position: Float = if (wheelImageBitmap == null) { val point = wheelPoint.coerceIn( minimumValue = 0f, - maximumValue = bitmapSize.width.toFloat() + maximumValue = bitmapSize.width.toFloat(), ) point / bitmapSize.width } else { val point = wheelPoint.coerceIn( minimumValue = 0f, - maximumValue = bitmapSize.width.toFloat() + maximumValue = bitmapSize.width.toFloat(), ) point / bitmapSize.width } @@ -158,19 +158,19 @@ public fun AlphaSlider( val position: Float = if (wheelImageBitmap == null) { val point = wheelPoint.coerceIn( minimumValue = 0f, - maximumValue = bitmapSize.width.toFloat() + maximumValue = bitmapSize.width.toFloat(), ) point / bitmapSize.width } else { val point = wheelPoint.coerceIn( minimumValue = 0f, - maximumValue = bitmapSize.width.toFloat() + maximumValue = bitmapSize.width.toFloat(), ) point / bitmapSize.width } controller.setAlpha(position.coerceIn(0f, 1f), fromUser = true) } - } + }, ) { drawIntoCanvas { canvas -> backgroundBitmap?.let { @@ -184,7 +184,7 @@ public fun AlphaSlider( colors = listOf(startColor, endColor), from = Offset.Zero, to = Offset(bitmapSize.width.toFloat(), bitmapSize.height.toFloat()), - tileMode = TileMode.Clamp + tileMode = TileMode.Clamp, ) colorPaint.shader = shader canvas.drawRoundRect( @@ -194,7 +194,7 @@ public fun AlphaSlider( bottom = bitmapSize.height.toFloat(), radiusX = borderRadius.value, radiusY = borderRadius.value, - paint = colorPaint + paint = colorPaint, ) // draw wheel bitmap on the canvas. @@ -202,26 +202,26 @@ public fun AlphaSlider( val position = controller.alpha.value val point = (bitmapSize.width * position).coerceIn( minimumValue = 0f, - maximumValue = bitmapSize.width.toFloat() + maximumValue = bitmapSize.width.toFloat(), ) canvas.drawCircle( Offset(x = point, y = bitmapSize.height / 2f), wheelRadius.toPx(), - wheelPaint + wheelPaint, ) } else { val position = controller.alpha.value val point = (bitmapSize.width * position).coerceIn( minimumValue = 0f, - maximumValue = bitmapSize.width.toFloat() + maximumValue = bitmapSize.width.toFloat(), ) canvas.drawImage( wheelImageBitmap, Offset( x = point - (wheelImageBitmap.width / 2), - y = bitmapSize.height / 2f - wheelImageBitmap.height / 2 + y = bitmapSize.height / 2f - wheelImageBitmap.height / 2, ), - Paint() + Paint(), ) } } diff --git a/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/AlphaTile.kt b/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/AlphaTile.kt index b948ec4..f6ec81e 100644 --- a/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/AlphaTile.kt +++ b/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/AlphaTile.kt @@ -52,7 +52,7 @@ public fun AlphaTile( selectedColor: Color = Color.Transparent, tileOddColor: Color = defaultTileOddColor, tileEvenColor: Color = defaultTileEvenColor, - tileSize: Dp = 12.dp + tileSize: Dp = 12.dp, ) { val density = LocalDensity.current var backgroundBitmap: ImageBitmap? = null @@ -68,7 +68,11 @@ public fun AlphaTile( val size = newSize.takeIf { it.width != 0 && it.height != 0 } ?: return@onSizeChanged val drawable = - AlphaTileDrawable(with(density) { tileSize.toPx() }, tileOddColor, tileEvenColor) + AlphaTileDrawable( + with(density) { tileSize.toPx() }, + tileOddColor, + tileEvenColor, + ) backgroundBitmap ?.asAndroidBitmap() ?.recycle() @@ -79,12 +83,12 @@ public fun AlphaTile( 0, 0, backgroundCanvas.nativeCanvas.width, - backgroundCanvas.nativeCanvas.height + backgroundCanvas.nativeCanvas.height, ) drawable.draw(backgroundCanvas.nativeCanvas) } bitmapSize = size - } + }, ) { drawIntoCanvas { canvas -> backgroundBitmap?.let { @@ -94,7 +98,7 @@ public fun AlphaTile( 0f, bitmapSize.width.toFloat(), bitmapSize.height.toFloat(), - colorPaint + colorPaint, ) } } diff --git a/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/AlphaTileDrawable.kt b/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/AlphaTileDrawable.kt index e0133b2..0482c8a 100644 --- a/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/AlphaTileDrawable.kt +++ b/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/AlphaTileDrawable.kt @@ -40,11 +40,11 @@ import androidx.compose.ui.graphics.asAndroidBitmap public class AlphaTileDrawable constructor( tileSize: Float, tileOddColor: Color, - tileEvenColor: Color + tileEvenColor: Color, ) : Drawable() { private val androidPaint: android.graphics.Paint = android.graphics.Paint( - android.graphics.Paint.ANTI_ALIAS_FLAG + android.graphics.Paint.ANTI_ALIAS_FLAG, ) init { @@ -69,7 +69,7 @@ public class AlphaTileDrawable constructor( androidPaint.shader = BitmapShader( imageBitmap.asAndroidBitmap(), Shader.TileMode.REPEAT, - Shader.TileMode.REPEAT + Shader.TileMode.REPEAT, ) } @@ -92,7 +92,7 @@ public class AlphaTileDrawable constructor( @Deprecated( message = "This method will be deprecated on the future Android SDK", - replaceWith = ReplaceWith(expression = "getOpacity") + replaceWith = ReplaceWith(expression = "getOpacity"), ) override fun getOpacity(): Int = PixelFormat.OPAQUE } diff --git a/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/BitmapCalculator.kt b/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/BitmapCalculator.kt index 781fd72..da44ab1 100644 --- a/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/BitmapCalculator.kt +++ b/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/BitmapCalculator.kt @@ -35,7 +35,7 @@ internal object BitmapCalculator { bitmap, targetSize.width, targetSize.height, - false + false, ) } diff --git a/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/BrightnessSlider.kt b/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/BrightnessSlider.kt index 3d47917..87976f0 100644 --- a/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/BrightnessSlider.kt +++ b/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/BrightnessSlider.kt @@ -79,7 +79,7 @@ public fun BrightnessSlider( color = wheelColor alpha = wheelAlpha }, - initialColor: Color? = null + initialColor: Color? = null, ) { var backgroundBitmap: ImageBitmap? = null var bitmapSize = IntSize(0, 0) @@ -117,7 +117,7 @@ public fun BrightnessSlider( bottom = size.height.toFloat(), radiusX = borderRadius.value, radiusY = borderRadius.value, - paint = borderPaint + paint = borderPaint, ) } bitmapSize = size @@ -129,13 +129,13 @@ public fun BrightnessSlider( val position: Float = if (wheelImageBitmap == null) { val point = wheelPoint.coerceIn( minimumValue = 0f, - maximumValue = bitmapSize.width.toFloat() + maximumValue = bitmapSize.width.toFloat(), ) point / bitmapSize.width } else { val point = wheelPoint.coerceIn( minimumValue = 0f, - maximumValue = bitmapSize.width.toFloat() + maximumValue = bitmapSize.width.toFloat(), ) point / bitmapSize.width } @@ -149,19 +149,19 @@ public fun BrightnessSlider( val position: Float = if (wheelImageBitmap == null) { val point = wheelPoint.coerceIn( minimumValue = 0f, - maximumValue = bitmapSize.width.toFloat() + maximumValue = bitmapSize.width.toFloat(), ) point / bitmapSize.width } else { val point = wheelPoint.coerceIn( minimumValue = 0f, - maximumValue = bitmapSize.width.toFloat() + maximumValue = bitmapSize.width.toFloat(), ) point / bitmapSize.width } controller.setBrightness(position.coerceIn(0f, 1f), fromUser = true) } - } + }, ) { drawIntoCanvas { canvas -> backgroundBitmap?.let { @@ -173,7 +173,7 @@ public fun BrightnessSlider( colors = listOf(Color.Black, controller.pureSelectedColor.value), from = Offset.Zero, to = Offset(bitmapSize.width.toFloat(), bitmapSize.height.toFloat()), - tileMode = TileMode.Clamp + tileMode = TileMode.Clamp, ) colorPaint.shader = shader canvas.drawRoundRect( @@ -183,7 +183,7 @@ public fun BrightnessSlider( bottom = bitmapSize.height.toFloat(), radiusX = borderRadius.value, radiusY = borderRadius.value, - paint = colorPaint + paint = colorPaint, ) // draw wheel bitmap on the canvas. @@ -191,31 +191,32 @@ public fun BrightnessSlider( val position = controller.brightness.value val point = (bitmapSize.width * position).coerceIn( minimumValue = 0f, - maximumValue = bitmapSize.width.toFloat() + maximumValue = bitmapSize.width.toFloat(), ) canvas.drawCircle( Offset(x = point, y = bitmapSize.height / 2f), wheelRadius.toPx(), - wheelPaint + wheelPaint, ) } else { val position = controller.brightness.value val point = (bitmapSize.width * position).coerceIn( minimumValue = 0f, - maximumValue = bitmapSize.width.toFloat() + maximumValue = bitmapSize.width.toFloat(), ) canvas.drawImage( wheelImageBitmap, Offset( x = point - (wheelImageBitmap.width / 2), - y = bitmapSize.height / 2f - wheelImageBitmap.height / 2 + y = bitmapSize.height / 2f - wheelImageBitmap.height / 2, ), - Paint() + Paint(), ) } if (initialColor != null && !isInitialized) { isInitialized = true - val brightness = max(max(initialColor.red, initialColor.green), initialColor.blue) + val brightness = + max(max(initialColor.red, initialColor.green), initialColor.blue) controller.setBrightness(brightness, fromUser = false) } } diff --git a/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/ColorEnvelope.kt b/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/ColorEnvelope.kt index 3ef8f30..c673216 100644 --- a/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/ColorEnvelope.kt +++ b/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/ColorEnvelope.kt @@ -30,5 +30,5 @@ import androidx.compose.ui.graphics.Color public data class ColorEnvelope( val color: Color, val hexCode: String, - val fromUser: Boolean + val fromUser: Boolean, ) diff --git a/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/ColorPickerController.kt b/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/ColorPickerController.kt index 0f646af..b2f7141 100644 --- a/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/ColorPickerController.kt +++ b/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/ColorPickerController.kt @@ -119,7 +119,9 @@ public class ColorPickerController { /** Set an [ImageBitmap] to draw on the canvas as a palette. */ public fun setPaletteImageBitmap(imageBitmap: ImageBitmap) { val targetSize = canvasSize.value.takeIf { it.width != 0 && it.height != 0 } - ?: throw IllegalAccessException("Can't set an ImageBitmap before initializing the canvas") + ?: throw IllegalAccessException( + "Can't set an ImageBitmap before initializing the canvas", + ) val copiedBitmap = imageBitmap.asAndroidBitmap().copy(Bitmap.Config.ARGB_8888, false) val resized = when (paletteContentScale) { @@ -322,7 +324,7 @@ public class ColorPickerController { ( atan2( y2.toDouble(), - -x2.toDouble() + -x2.toDouble(), ) / Math.PI * 180f ).toFloat() + 180 ).also { hsv[0] = it } diff --git a/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/HsvBitmapDrawable.kt b/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/HsvBitmapDrawable.kt index 0e330df..0f903d5 100644 --- a/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/HsvBitmapDrawable.kt +++ b/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/HsvBitmapDrawable.kt @@ -37,7 +37,7 @@ import kotlin.math.min */ internal class HsvBitmapDrawable constructor( resources: Resources, - bitmap: Bitmap + bitmap: Bitmap, ) : BitmapDrawable(resources, bitmap) { private val huePaint: Paint = Paint(Paint.ANTI_ALIAS_FLAG) @@ -60,9 +60,9 @@ internal class HsvBitmapDrawable constructor( Color.CYAN, Color.GREEN, Color.YELLOW, - Color.RED + Color.RED, ), - floatArrayOf(0.000f, 0.166f, 0.333f, 0.499f, 0.666f, 0.833f, 0.999f) + floatArrayOf(0.000f, 0.166f, 0.333f, 0.499f, 0.666f, 0.833f, 0.999f), ) huePaint.shader = sweepShader @@ -72,7 +72,7 @@ internal class HsvBitmapDrawable constructor( radius, Color.WHITE, 0x00FFFFFF, - Shader.TileMode.CLAMP + Shader.TileMode.CLAMP, ) saturationPaint.shader = saturationShader @@ -90,7 +90,7 @@ internal class HsvBitmapDrawable constructor( @Deprecated( message = "This method will be deprecated on the future Android SDK", - replaceWith = ReplaceWith(expression = "getOpacity") + replaceWith = ReplaceWith(expression = "getOpacity"), ) override fun getOpacity(): Int { return PixelFormat.OPAQUE diff --git a/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/HsvColorPicker.kt b/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/HsvColorPicker.kt index 48bba1b..a375b93 100644 --- a/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/HsvColorPicker.kt +++ b/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/HsvColorPicker.kt @@ -63,7 +63,7 @@ public fun HsvColorPicker( controller: ColorPickerController, wheelImageBitmap: ImageBitmap? = null, onColorChanged: ((colorEnvelope: ColorEnvelope) -> Unit)? = null, - initialColor: Color? = null + initialColor: Color? = null, ) { var isInitialized by remember { mutableStateOf(false) } val context = LocalContext.current @@ -102,7 +102,7 @@ public fun HsvColorPicker( 0, 0, size.width, - size.height + size.height, ) } @@ -114,7 +114,9 @@ public fun HsvColorPicker( val bitmapWidth: Int = it.asAndroidBitmap().width val bitmapHeight: Int = it.asAndroidBitmap().height - if (bitmapWidth * mDrawableRect.height() > mDrawableRect.width() * bitmapHeight) { + if (bitmapWidth * mDrawableRect.height() > + mDrawableRect.width() * bitmapHeight + ) { scale = mDrawableRect.height() / bitmapHeight.toFloat() dx = (mDrawableRect.width() - bitmapWidth * scale) * 0.5f } else { @@ -127,7 +129,7 @@ public fun HsvColorPicker( // post translate the matrix with the specified translation. shaderMatrix.postTranslate( (dx + 0.5f) + mDrawableRect.left, - (dy + 0.5f) + mDrawableRect.top + (dy + 0.5f) + mDrawableRect.top, ) // set the shader matrix to the controller. @@ -143,7 +145,7 @@ public fun HsvColorPicker( detectDragGestures { change, _ -> controller.selectByCoordinate(change.position.x, change.position.y, true) } - } + }, ) { drawIntoCanvas { canvas -> // draw hsv bitmap on the canvas. @@ -156,13 +158,13 @@ public fun HsvColorPicker( canvas.drawCircle( Offset(point.x, point.y), controller.wheelRadius.toPx(), - controller.wheelPaint + controller.wheelPaint, ) } else { canvas.drawImage( wheelBitmap, Offset(point.x - wheelBitmap.width / 2, point.y - wheelBitmap.height / 2), - Paint() + Paint(), ) } val palette = controller.paletteBitmap @@ -175,7 +177,7 @@ public fun HsvColorPicker( (initialColor.red * 255).toInt(), (initialColor.green * 255).toInt(), (initialColor.blue * 255).toInt(), - hsv + hsv, ) val angle = (Math.PI / 180f) * hsv[0] * (-1) val saturationVector = pickerRadius * hsv[1] diff --git a/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/ImageColorPicker.kt b/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/ImageColorPicker.kt index fc63c50..da2aa93 100644 --- a/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/ImageColorPicker.kt +++ b/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/ImageColorPicker.kt @@ -58,7 +58,7 @@ public fun ImageColorPicker( paletteImageBitmap: ImageBitmap, wheelImageBitmap: ImageBitmap? = null, paletteContentScale: PaletteContentScale = PaletteContentScale.FIT, - onColorChanged: ((colorEnvelope: ColorEnvelope) -> Unit)? = null + onColorChanged: ((colorEnvelope: ColorEnvelope) -> Unit)? = null, ) { val coroutineScope = rememberCoroutineScope() DisposableEffect(key1 = controller) { @@ -89,13 +89,14 @@ public fun ImageColorPicker( when (event.action) { MotionEvent.ACTION_DOWN, MotionEvent.ACTION_MOVE, - MotionEvent.ACTION_UP -> { + MotionEvent.ACTION_UP, + -> { controller.selectByCoordinate(event.x, event.y, true) true } else -> false } - } + }, ) { drawIntoCanvas { canvas -> // draw image bitmap on the canvas. @@ -134,7 +135,7 @@ public fun ImageColorPicker( // post translate the matrix with the specified translation. shaderMatrix.postTranslate( (dx + 0.5f) + mDrawableRect.left, - (dy + 0.5f) + mDrawableRect.top + (dy + 0.5f) + mDrawableRect.top, ) // apply the scaled matrix to the shader. shader.setLocalMatrix(shaderMatrix) @@ -156,13 +157,13 @@ public fun ImageColorPicker( canvas.drawCircle( Offset(point.x, point.y), controller.wheelRadius.toPx(), - controller.wheelPaint + controller.wheelPaint, ) } else { canvas.drawImage( wheelBitmap, Offset(point.x - wheelBitmap.width / 2, point.y - wheelBitmap.height / 2), - Paint() + Paint(), ) } } diff --git a/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/PointMapper.kt b/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/PointMapper.kt index 95529b6..2e3cdf3 100644 --- a/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/PointMapper.kt +++ b/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/PointMapper.kt @@ -39,7 +39,7 @@ internal object PointMapper { private fun approximatedPoint( controller: ColorPickerController, start: PointF, - end: PointF + end: PointF, ): PointF { if (getDistance(start, end) <= 3) return end val center: PointF = getCenterPoint(start, end) @@ -75,7 +75,7 @@ internal object PointMapper { ( abs(end.x - start.x) * abs(end.x - start.x) + abs(end.y - start.y) * abs(end.y - start.y) - ).toDouble() + ).toDouble(), ).toInt() } }