Re: [pyjaco] pyjaco and HTML5 canvas element

113 views
Skip to first unread message

Christian Iversen

unread,
Oct 7, 2012, 1:56:16 PM10/7/12
to pyj...@googlegroups.com
On 2012-10-07 16:46, stochastis wrote:
> Hi there!
>
> I have a technical question to ask about "pyjaco". Is it possible to
> have access to the HTML5 <canvas> element via "pyjaco"?

Certainly. You can do something like this:

@JSVar("document", "canvas")
def example(x, y):
canvas = document.getElementById("mycanvas")
canvas.foo(js(x), js(y))

Notice there are some shortcomings to the JSVar-based method, but while
we are implementing the next-generation support, this is the best way to
do it.

Be sure to use js() for all python values you pass to javascript, and
py() for all js results you pass back to python code.

> I am thinking about to create a game engine (but it will not restricted
> only at this, something like a graphics library) with pyjaco that is
> why I am asking. For this project, I want to take advantage of Python
> language's capabilities.

The above example is not tested, but it should work. Let me know if you
run into any trouble :)

--
Med venlig hilsen
Christian Iversen

Samuel Ytterbrink

unread,
Oct 7, 2012, 2:46:30 PM10/7/12
to pyj...@googlegroups.com
@stochastis

I'am a little bit skeptical, on the subject of performance. Game engines need to be very efficient, and which ever tool you take form the shelf that will translate python to javascript will have a large overhead, especially if you want it to behave python like, with all the quirks and features python has.

With that said, i think you should first implement it in javascript, and build a interface for python, with pyjaco if you so wish.

2012/10/7 Christian Iversen <chri...@iversen-net.dk>


--
You are subscribed to the Google Group pyj...@googlegroups.com
To unsubscribe from this group, send email to
pyjaco+unsubscribe@googlegroups.com



--
//Samuel Ytterbrink

Christian Iversen

unread,
Oct 7, 2012, 3:25:50 PM10/7/12
to pyj...@googlegroups.com
On 2012-10-07 20:46, Samuel Ytterbrink wrote:
> @stochastis
>
> I'am a little bit skeptical, on the subject of performance. Game engines
> need to be very efficient, and which ever tool you take form the shelf
> that will translate python to javascript will have a large
> overhead, especially if you want it to behave python like, with all the
> quirks and features python has.
>
> With that said, i think you should first implement it in javascript, and
> build a interface for python, with pyjaco if you so wish.

I agree. No matter how efficient we make pyjaco, there's going to be an
overhead to ensure the more complicated, more reasonable semantics of
Python. So, if you can implement a JS library for controlling the game,
and only call high-level functions from JS, that would probably be a
good idea.
Reply all
Reply to author
Forward
0 new messages