You would need a way of knowing which attachment is that background. Then you can get the attachment and inspect it to determine its size and position.
You could use the first slot found on the root bone, but there may be multiple. The order of slots is not controlled on the bone, it is done in the draw order. I think it would be easier to use a name, like bg
. It should still be under the root bone though, so you don't need to compute the world position.
If you use a region attachment, it has x, y, width, and height properties. Note the X and Y are the center of the region attachment.
It looks like you are using a clipping attachment. If you name that bg
and put it in a bg
slot, then you can easily find it. Loop through the vertices and take the min and max values for X and Y out of all the vertices. minX
and minY
are your viewport X and Y. maxX - minX
and maxY - minY
are the viewport width and height.
Make sure the clipping attachment is not weighted to bones, otherwise the vertices are in a more complex format. They shouldn't be animating the clipping attachment vertices for the viewport anyway.