v8ui: mgraphics.redraw() only executes when patcher opened + 1 more bug/feature request

Nodanoma's icon

Hi,

Perhaps no-one is concerned about such a usecase but I do wonder whether it is intended for the MGraphics' paint()-function to only execute when its patcher is opened?

I could do with a fix if this is to be concidered a bug. The shared patch demonstrates this behaviour:

Max Patch
Copy patch and select New From Clipboard in Max.

On another note, the command mgraphics.[Image()].tonamedmatrix() does not work as expected. The image is correctly rendered in the v8ui but when sent to the named matrix, it creates margins at the botto and right axes thus resulting in an incorrect aspect ratio. The matrix' dimensions also do not match those of the Image() — is there a reliable method to rescale the contents correctly and/or bypass this behaviour? Example is illustrated in patch too.

matrix should have square-dimensions but is rectangular due to incorrect transport from Image() to JitterMatrix(). Aspect Ratio is incorrect

Any fix/hints?

Thank you!

Joshua Kit Clayton's icon

Only painting when visible is expected and desirable behavior for all ui objects in Max. If you want to render with an mgraphics instance, you can create one in any js/v8 object and use that one to paint instead of the global jsui/v8ui mgraphics instance which is tied to the UI object painting.

There wasn't a JS file included with your example, so I can't comment more about the other issues. It sounds like maybe there is a size mismatch somewhere.

Max Patch
Copy patch and select New From Clipboard in Max.

Nodanoma's icon

This answer has helped massively, thank you.
I had tried pushing the code to a v8 but it threw an error while your highly simplified version (withut the erroneous lines) makes all the more sense and of course works as expected.

The aspect ratio issue seems to have hailed from the push_group() / pop_group() combination since pushing the entire MGraphics-context to the Image works neatly now. Thank you.

And yes, the patch I shared had not copied the embedded v8ui-code, sorry. But you've nailed it!

T