0

How do you use canvas with Brython?

I tried to use canvas with Brython but it won't work. I did requestAnimationFrame but it throws an error, I do a while True but it just doesn't run at all. https://code.sololearn.com/Wp3M9Mu0B60L/?ref=app

8th May 2021, 11:15 AM
Clueless Coder
Clueless Coder - avatar
3 Answers
+ 2
There is no requestAnimationFrame global variable in Brython. An alternative function request_animation_frame from browser.timer is used. I tried to fix your code with it, but it gives another error about object cloning; I cannot help you with it for now. And I have found a short introduction to using Canvas2D with Brython, it may help you: https://agentultra.com/blog/JUMP_LINK__&&__python__&&__JUMP_LINK-and-canvas2d-with-brython/ .
8th May 2021, 11:39 AM
#0009e7 [get]
#0009e7 [get] - avatar
+ 1
get I got it to work. If you import "window" and use "window.requestAnimationFrame"it works As for the link, unfortunately it gets blocked on Firefox for insecure connection :/
8th May 2021, 12:49 PM
Clueless Coder
Clueless Coder - avatar
+ 1
get dammit another bug. After commenting stuff out, it's caused by window.requestAnimationFrame for some reason
8th May 2021, 1:04 PM
Clueless Coder
Clueless Coder - avatar