mgraphics vs. canvas

jml's icon

i'm curious as to whether or not one of these will be supported for longer than the other, and also wondering why it would be advantageous to use either of them... i realize that canvas code is portable, but i'm still curious why the option exists. is it that people are looking for a more "native" mgraphics rendering engine that would be faster?

thx
jml

nick rothwell | project cassiel's icon

I've done a whole pile of UI stuff using the Sketch API, and I think I bypassed Canvas altogether. (There's nothing about it in Max Help.) I'm using MGraphics at the moment, because it's new and shiny (I'd like higher performance than Sketch) but am really waiting for better documentation.

pid's icon

i agree with nick regarding documentation.

i have been using mgraphics exclusively since max6 release and it is mainly fantastic. plenty experimentation required though.

the thing about canvas in max6 is that it is really there as a convenience right now, as in max6 it is just a compatibility layer between canvas syntax and mgraphics. you can see this by looking at the file
/Max6/Cycling '74/jsextensions/CanvasExtension.js

i expect ('my guess is') that it is there now as eventually canvas will be more fully integrated into max. anyway for now, canvas will be significantly slower than a native implementation, and slower than mgraphics.

ej says (i seem to remember) that his ej.function object got a 250 % speed increase porting from sketch to mgraphics - that is significant. there are still a few things in sketch though that are useful. i am no expert though, just a tinkerer.

my personal huge wish / feature request is that one day cycling74 do away with compatability layers and get rid of jweb and fully port/integrate the entire webkit into max. i think this would be very powerful and very useful.

2cents.

jml's icon

thanks guys. for the time being, i think i might stick with mgraphics as well, but my intuition is to use canvas (the same type of intuition that led me to use js/jsui in the first place), as i kill multiple birds with one graphic stone.

nick rothwell | project cassiel's icon

Darwin's November Patch-a-day examples cover a lot of MGraphics ground: https://cycling74.com/tutorials/november-patch-a-day/

jml's icon

yeah; saw that. i've been following it...
thanks nick!

there's (currently) not a lot of that sort of coverage on max canvas.
i'm converting some canvas code atm... it'll work out. i'm going to give up on it for the time being and come back if it gets more love.
didn't see a way to notify jsui of patching vs. pres mode, for ex.

jml