Stylianos Gakis
10/20/2023, 3:55 PMplaceholder: Painter? = null,
to show on the screen, I am trying to figure out a way to provide a Painter
which paints a solid color but with a specific shape (with some rounded corners etc.) but I can not figure out the right API to use here and I am pretty sure there must be something I can use. Any pointers?Francesc
10/20/2023, 3:59 PMColorPainter
that paints a solid color, an option would be to clone that and tweak it to add rounded cornersStylianos Gakis
10/20/2023, 4:02 PMoverride fun DrawScope.onDraw() {
val outline = shape.createOutline(size, layoutDirection, this)
when (outline) {
is Outline.Generic -> {
drawPath(
outline.path,
color = color,
alpha = alpha,
colorFilter = colorFilter,
)
}
is Outline.Rectangle -> {
drawRect(color = color, alpha = alpha, colorFilter = colorFilter)
}
is Outline.Rounded -> {
// drawCircle maybe not what I want here exactly, but good enough for me for now
drawCircle(color = color, alpha = alpha, colorFilter = colorFilter)
}
}
}
Seems to work perfectly fine actually. In my case I only needed the Outline.Generic
case, since I want to use this squircle shape here, but I added the others just in case.remember*
companion function just works for me 👍
If there is some built-in way to do this I would love to know about it still, but for now this works well for me