Код: Выделить всё
androidx.compose.foundation.Canvas(
modifier = Modifier
.fillMaxSize()
.pointerInput(true) {
detectDragGestures { change, dragAmount ->
change.consume()
val line = Line(
start = change.position - dragAmount,
end = change.position,
color = currentColor
)
lines.add(line)
}
}
) {
val neonGradient = Brush.linearGradient(
colors = listOf(
Color.Red.copy(alpha = 0.7f),
Color.White,
Color.Red.copy(alpha = 0.7f)
)
)
lines.forEach { line->
drawLine(
brush = neonGradient,
start = line.start,
end = line.end,
strokeWidth = line.strokeWidth,
cap = StrokeCap.Round
)
}
}
Подробнее здесь: https://stackoverflow.com/questions/794 ... ck-compose
Мобильная версия