-
-
Save DUMA042/5076a8919e4eb4210cdb5de2c8101ffd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun DrawRectangle(rect: Rect?) { | |
// Convert the Android Rect to a Compose Rect | |
val composeRect = rect?.toComposeRect() | |
// Draw the rectangle on a Canvas if the rect is not null | |
composeRect?.let { | |
Canvas(modifier = Modifier.fillMaxSize()) { | |
drawRect( | |
color = Color.Red, | |
topLeft = Offset(it.left, it.top), // Set the top-left position | |
size = Size(it.width, it.height), // Set the size of the rectangle | |
style = Stroke(width = 5f) // Use a stroke style with a width of 5f | |
) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment