Is there a way to export a composable as SVG? I ha...
# compose-desktop
m
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
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)
    }
}
@Chrimaeon you can remove that "no" reaction :)
today i learned 3
👍 1