Open mistrydarshan99 opened 1 year ago
You can try using the drawWithContent
modifier, and draw your shape with BlendMode.DstIn
after drawing the content.
I think Outline.Generic(shape.toPath()) should work if you implement compose Shape.
Something like
class PillShape(
val dpSize: DpSize
) : Shape {
val height = dpSize.height.value
val width = dpSize.width.value
val Pill = RoundedPolygon.pill(
smoothing = 0.3f,
height = height,
width = width,
centerX = width,
centerY = height
)
val scaleFactor = height
override fun createOutline(
size: Size,
layoutDirection: LayoutDirection,
density: Density
): Outline {
return Outline.Generic(Pill.toPath().apply {
// Why?
transform(scaleMatrix(sx = 1.35f, sy = 1.35f))
}.asComposePath())
}
}
I have a below composable function in which I need to clip RoundedPolygon but not able to clip because clip function take Shape as a parameter.
Is there any way to clip RoundedPolygon ?