Vinay Gaba
05/18/2020, 4:58 PMContextDrawScope
and clipRRect
was removed from it. What’s the alternative if I want to clip a rect with rounded corners?private data class RoundedCornerClipModifier() : DrawModifier {
override fun ContentDrawScope.draw() {
val shape = RoundedCornerShape(20.dp)
clip(shape)
drawContent()
}
}
Adam Powell
05/18/2020, 6:04 PMKazemihabib1996
05/18/2020, 6:20 PMval RRectPath = Path().apply {
addRRect(RRect(rect = Rect.fromCircle(Offset(100f, 100f), 100f),
topLeft = Radius(10f, 10f),
topRight = Radius(10f, 10f),
bottomLeft = Radius(10f, 10f),
bottomRight = Radius(10f, 10f)))
}
clipPath(RRectPath, ClipOp.intersect) {
this@draw.drawContent()
}
Vinay Gaba
05/18/2020, 6:21 PMKazemihabib1996
05/18/2020, 6:24 PMval shape = RoundedCornerShape(20.dp)
clip(shape)
Here the clip
is a modifier not a CanvasScope functionfun Modifier.test(
): Modifier = composed {
val shape = RoundedCornerShape(20.dp)
clip(shape)
}
Vinay Gaba
05/18/2020, 6:33 PMprivate data class RoundedCornerClipModifier() : DrawModifier {
override fun ContentDrawScope.draw() {
val shape = RoundedCornerShape(20.dp)
clip(shape)
drawContent()
}
}
Kazemihabib1996
05/18/2020, 6:52 PMModifier.clip(shape: Shape)
is a modifier itself and just calling it in draw
phase does nothing.
it just returns an instance of private data class SimpleDrawLayerModifier(...)
.Adam Powell
05/18/2020, 6:57 PMVinay Gaba
05/18/2020, 7:44 PMNader Jawad
05/18/2020, 7:46 PMVinay Gaba
05/18/2020, 8:06 PM