Is there a way to export a composable as SVG? I have an element I'd like to have as image, but I can't find a way to generate an SVG based on the element.
🚫 2
martmists
03/01/2025, 8:05 PM
Figured it out:
Copy code
fun main() {
val outFile = File(...)
outFile.outputStream().use {
val canvas = SVGCanvas.make(Rect.makeWH(...), OutputWStream(it))
val scene = MultiLayerComposeScene()
scene.setContent {
// Composable here
}
scene.render(canvas.asComposeCanvas(), 0)
}
}