akshay2211 / DrawBox

DrawBox is a multi-purpose tool to draw anything on canvas, written completely on jetpack compose.
https://ak1.io/DrawBox/
Apache License 2.0
303 stars 41 forks source link

Content Drawn can cross boundary of the declared modifier #50

Open sai1153 opened 1 year ago

sai1153 commented 1 year ago

WhatsApp Image 2023-09-03 at 12 11 35 AM

i think it can be avoided by adding a if condition in updateLatestPath(newPoint) function which checks whether the point lies inside the given modifier, if it lies inside then only add the newPoint

lumec commented 11 months ago

Same here

cvetojevichbojan commented 11 months ago

Try adding clipToBounds to your modifier DrawBox modifier:

Box(
            modifier = Modifier
                .padding(top = 8.dp)
                .fillMaxSize(0.75f)
                .border(width = 1.dp, color = Color.DarkGray)
        ) {

DrawBox(drawController = controller, modifier = Modifier.fillMaxSize().**clipToBounds()** ....)

}
JustKhit commented 6 months ago

Try adding clipToBounds to your modifier DrawBox modifier:

Box(
            modifier = Modifier
                .padding(top = 8.dp)
                .fillMaxSize(0.75f)
                .border(width = 1.dp, color = Color.DarkGray)
        ) {

DrawBox(drawController = controller, modifier = Modifier.fillMaxSize().**clipToBounds()** ....)

}

Awesome. Thanks