Skip to content

Instantly share code, notes, and snippets.

@DevSrSouza
Last active August 1, 2021 20:41
Show Gist options
  • Save DevSrSouza/e6d0d540b37ac0b84ae2d0cbf509bba4 to your computer and use it in GitHub Desktop.
Save DevSrSouza/e6d0d540b37ac0b84ae2d0cbf509bba4 to your computer and use it in GitHub Desktop.
Compose Desktop render to png test
fun main() {
val window = TestComposeWindow(width = 1024, height = 300)
window.setContent {
MainUi()
}
File(Paths.get("").toAbsolutePath().toString()).writeBytes(window.surface.makeImageSnapshot().encodeToData()!!.bytes)
}
@Composable
fun MainUi() {
MaterialTheme {
Surface(
modifier = Modifier.fillMaxSize(),
color = Color.Transparent
) {
Column {
Button({}) { Text("Test 1") }
Button({}) { Text("Test 2") }
Button({}) { Text("Test 3") }
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment