If I got a Shape which internally is a Shape.Gener...
# compose
s
If I got a Shape which internally is a Shape.Generic, and I want to read its path, is my best bet to try to cast it to a Shape.Generic and use the path variable from it? The context is that I want to take an existing shape, and create a new Shape.Generic by adding the path of that shape, and add another shape into it. I can’t do it using just Path() { addOutline(myShape); addPath(thatOtherPath) }, since I want that other path to go outside the bounds of my outline.
Basically trying to achieve this. And with casting to Shape.Generic and getting the path out of it, it works perfectly fine, but I wonder if there’s another way which would also work for non-generic shapes which doesn’t force me to force cast like that.
r
There is an extension function on Path.addShape(), that allows you to add the shape to your path.. Might work?
s
Yeah, but I couldn’t do something like addOutline(outline, offset), it only accepts the outline exactly as it is, which didn’t let me move it a bit further down so that I get the space for the arrow on the top right. This is what I’ve done now, which is take this squirle-ish shape and take its path with
val squirclePath: Path = (squircleOutline as Outline.Generic).path
so that I can then use it like
addPath(path = squirclePath, offset = Offset(0f, arrowHeight))
so that I offset it accordingly. It does work after all, just don’t love that cast part 😄
Oh I just read you said
addShape
not
addPath
but I don’t see that function. Might be in an artifact I am not pulling in right now.
No hits here https://cs.android.com/search?q=addShape 👀 Could it be that it’s some API that you’ve used before but isn’t available in the public code at least?