compose web draws into a canvas.. what javascript ...
# compose-web
n
compose web draws into a canvas.. what javascript hooks would i need to adjust the canvas to the browser window size each time it gets resized ? i tried
Copy code
function resize_canvas(){
    canvas = document.getElementById("ComposeTarget");
    canvas.width  = window.innerWidth;
    canvas.height = window.innerHeight;
}
with
Copy code
<body onresize="resize_canvas()">
and.. although that resizes the canvas.. it stops rendering
h
what do you mean by
compose web draws into a canvas
? It does not by default with the current dom api.
👍🏻 1
n
at least the example i worked from used a canvas .. and when i try to use
renderComposable(rootElementId = "root")
it seems to throw for me.. so i used the canvas for a while i guess i will try to make DOm renderer work
h
Currently, compose does not support canvas and you have to use it by yourself. 🤔
n
Wonder where i got the sample from that uses skia to render composable on a canvas then
h
The MPP falling balls example uses the experimental canvas api. Currently, the Dom api is published and "stable". At the start, JB tried to convert the compose foundation to the web too, by using the html Dom api. This was called widget api and is deprecated. the new replacement is not available at the moment.
n
Yeah i am using that.. But the dom api seems broken in the alphas
Making a desktop+web client seems hard right now with components that work on one but not the other..
h
Yeah, at the moment you can share your logic, but must use different UI apis