Computer scienceMobileJetpack ComposeRefinement

Shapes in Compose

Right Triangle

Report a typo

Fill in the gaps within the following code snippet to create a custom shape that draws a right triangle:

Fill in the gaps with the relevant elements
class RightTriangleShape : Shape {
    override fun createOutline(
        size: Size,
        layoutDirection: LayoutDirection,
        density: Density
    ): Outline {
        val path = Path().apply {
            moveTo(0f, 0f) // Start at top-left corner
            lineTo(0f, size.height) // Draw line to top-right corner 
            lineTo(size.width, ) // Draw line to bottom-left corner
            close()
        }
        return Outline.Generic(path)
    }
}
0fsize.widthsize.height100f

Create a free account to access the full topic