I am altering a `Shape` object by having an extens...
# compose
s
I am altering a
Shape
object by having an extension function like
private fun Shape.alter(someInput): Shape
, where the impl assumes that it's a Outline.generic so that I can grab its
Path
and combine it with another.
Copy code
return object : Shape {
  override fun createOutline(size: Size, layoutDirection: LayoutDirection, density: Density): Outline {
    val outline = this@alter.createOutline(size, layoutDirection, density)
    val path: Path = (outline as Outline.Generic).path
    val extraPath = Path()...
    return Outline.Generic(Path.combine(PathOperation.Union, extraPath, path))
  }
}
Now I want to be able to support also Outline.Rounded but I can't seem to find the right API to achieve this, if there is one. Any ideas?
1
Copy code
val squirclePath: Path = when (squircleOutline) {
 is Outline.Generic -> squircleOutline.path
 is Outline.Rectangle -> Path().apply { addRect(squircleOutline.rect) }
 is Outline.Rounded -> Path().apply { addRoundRect(squircleOutline.roundRect) }
}
Actually looks alright