I wanted to checkout how to draw to the canvas, bu...
# compose
a
I wanted to checkout how to draw to the canvas, but i wasnt sure where to keep my instances of Paint, which i want to reuse and not recreate on each onDraw(). I saw in the framework code this memo() function, which seems to serve this purpose. Unfortunately i didnt get it. Someone already understood how its working ?
Copy code
```with(+memo { DrawShapeCacheHolder() }) {
    lastShape = shape
    Draw { canvas, parentSize ->
...
}
m
I recommend you to watch Leland Richardson’s talk from AndroidDevSummit 2019 or better the one from KotlinConf 2019.
1
👍 1
l
Just outside of the draw, setup a paint
val paint = +memo { Paint() }
1
a
We're looking at automating a lot of the paint management, for now, yes, just memo one and modify as needed before use