![](/img/trans.png)
[英]How can I draw a shadow for a path in canvas in jetpack compose
[英]Jetpack Compose Path will draw outside canvas bounds
我有一個簽名框,在你簽名的那一刻,可以在畫布外畫畫。 我需要保持在畫布范圍內的路徑。 我可以在捕獲路徑時手動執行此操作,但我認為可能有一種自動方式。
Canvas(modifier = Modifier
.fillMaxWidth()
.height(100.dp)
.border(1.dp, MaterialTheme.colors.primaryVariant, shape = RoundedCornerShape(4.dp))
.pointerInput(Unit) {
detectDragGestures(onDragStart = {
touchMove(path, it.x, it.y, -1f, -1f, true)
}) { change, _ ->
change.consumeAllChanges()
touchMove(
path,
change.position.x,
change.position.y,
change.previousPosition.x,
change.previousPosition.y,
false
)
}
}) {
canvasWidth = size.width
canvasHeight = size.height
drawPath(path, color = Color.Blue, style = Stroke(width = 4f))
}
親愛的我。 寫完后想出了小步舞曲。
Modifier.clipToBounds()
奇怪的是,在任何示例中都沒有提到這一點。 我認為這是正常 android 剪輯的相反行為。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.