Код: Выделить всё
drawPaint variable
private var mDrawPaint = Paint().apply {
isAntiAlias = true
color = currentColor
style = Paint.Style.STROKE
strokeJoin = Paint.Join.ROUND
strokeCap = Paint.Cap.ROUND
Paint(Paint.DITHER_FLAG)
}
Код: Выделить всё
onTouch Event
override fun onTouchEvent(event: MotionEvent): Boolean {
scaleGestureDetector.onTouchEvent(event)
val touchX = event.x
val touchY = event.y
when (event.action) {
MotionEvent.ACTION_DOWN -> {
// First, check if the remove button itself is pressed
val shapeWithRemoveButtonPressed = shapes.find { shape ->
val removeButtonBounds = getRemoveButtonBounds(shape)
removeButtonBounds.contains(touchX, touchY)
}
if (shapeWithRemoveButtonPressed != null) {
shapes.remove(shapeWithRemoveButtonPressed)
invalidate()
return false
}
// Check if the touch is within any bitmap
for ((index, pair) in bitmaps.withIndex().reversed()) {
val (bitmap, position) = pair
val deleteButtonX = position.x + bitmap.width - deleteButtonSize
val deleteButtonY = position.y
if (touchX >= deleteButtonX && touchX = deleteButtonY && touchY = position.x && touchX = position.y && touchY
Подробнее здесь: [url]https://stackoverflow.com/questions/79166710/mdrawpaint-xfermode-porterduffxfermodeporterduff-mode-dst-out-is-not-working[/url]