Can't .position canvas
Closed this issue · 6 comments
I can't seem to change the position of the canvas via p5.dom. Other elements (.createP
, .createSlider
, etc.) work with .position
but not what's returned by get-canvas
of a reified Game
.
The get-canvas
function returns the raw canvas object, not the wrapped object. You could normal DOM API to adjust its position and other things, which is what that p5.dom library is doing underneath:
https://github.com/processing/p5.js/blob/master/lib/addons/p5.dom.js#L1259
Thank you.
Alternatively, there might be a way to re-wrap that canvas object so you can use that library. I haven't looked into it but I would guess there is a way.
If it isn't friendly to do it unwrapped I'll look into wrapping it and submit a patch. Unless I'm beaten to it.
Thanks for this and all your other projects too!
Well it actually started out as wrapped and I intentionally unwrapped it on this line:
https://github.com/oakes/play-cljs/blob/master/src/play_cljs/core.cljs#L387
So you'd just have to remove that part to make it return the wrapped object. The reason I did this is because I didn't necessarily want play-cljs to be dependent on the p5.dom library. Most web developers are familiar with working with the standard canvas object, so it made more sense to return that.
My suggestion was, perhaps there is a way to "re-wrap" the canvas object so you can use p5.dom if you want. I assume there is.
Yeah. For now I've just added a :canvas-p5
to the hidden-state-atom (and an associated get-*) but I'm not sure I like that. If I can think of something better I'll submit a patch.
Makes perfect sense about the canvas for web developers. This is my first foray into ClojureScript or web anything really so I appreciate your patience.