# FramebufferWidget clipping child rotating TransformWidget

[First post here so treat me gently! ]

So I have a SvgWidget (sw) as a child of a TransformWidget (tw) which itself is a child of a FramebufferWidget (fbw)

If I rotate the tw the shape of the underlying svg is getting clipped by what I assume is the bounding box of the fbw - I was using a simple square shape svg for testing and as it rotates, the corners get clipped.

If I simply have a sw as a child of tw and rotate the tw, the corners do not get clipped.

Therefore I’m assuming I’m not setting something correctly for the fbw. I’ve tried setting the fbw box size to twice that of the underlying tw and sw (tw is set as the same size as sw) and I’ve also tried setting the fbBox size to twice the size. The rotating tw still gets clipped.

Any ideas?

What is the the thing you are rotating used for? I could guess, but the answer will be imaginative.

It may end up as an indicator for the effect a CV input is having on a parameter knob. I’m also investigating the option of using nanovg to draw something as well however I decided I could knock up a little svg far quicker than I could code the nanovg stuff.

As I said, I have no problem achieving what I want without using a FramebufferWidget but as the CV input may operate at near audio rate I thought it safer to wrap it in a FramebufferWidget.

Little GIF of what I’m seeing. On the left tw only, on the right tw as a child of a FramebufferWidget. Whilst I can get around this by allowing for this within the underlying SVG, I’d really like to know how to fix this properly.

Couldn’t you increase the box.size in the second example to the size the diagonal.

That’s just the problem - increasing the box size appears to make no difference (see first post)

Right, but you should only increase the box size (to the diagonal of the square inside the box) not the actual square inside the box, this should remain the same size.

green outline being original box size, getting clipped

Yes I know, increase the frame buffer box size and leave everything else the same. I can verify the values of fbw->box.size.x (and y) are larger yet the rotating tw inside is still getting clipped. It’s as if there is something else needs increasing as well (hence why I also tried increasing fbBox.size as well to no avail.) I even tried the grow method of the fbw and nothing seems to have any effect.

FramebufferWidget calculates the bounding box of its children using Widget::getChildrenBoundingBox() and creates a GPU framebuffer to fit it. TranslateWidget doesn’t take into account its transformation when computing getChildrenBoundingBox() (because it’s implemented in Widget). It will return the bounding box based on the Widget::box, i.e. rectangular position and size.

So you will need to put a Widget between your FramebufferWidget and TransformWidget. Then set its size to the bounding box of the TransformWidget, which as @Coirt said, is something like \sqrt{2} times the square width, or maybe a couple pixels larger if the corners are being cut off due to antialiasing and subpixel details.

2 Likes

Gotcha - that makes sense. I’ll give that a try when I get a chance and although my ultimate use case in this instance doesn’t require it, having a more generic solution will be useful (plus it’s good to know what’s actually going on!) Many thanks @Vortico!