fredsa / playn

Cross platform game library for N≥4 platforms
0 stars 1 forks source link

accessing canvas element #124

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,
I want to use canvas bezier curves, but don't know how to access canvasElement. 
is it even possible or is there workaround to "cheat" framework.

Original issue reported on code.google.com by evgeni.g...@gmail.com on 23 Jan 2012 at 6:17

GoogleCodeExporter commented 9 years ago
You want to use HTML5 canvas's bezierCurveTo function ?

The problem is that it's not a generic function available for all platforms. It 
exists with HTML5 canvas element, but what for Java version or Android version ?

playn.core.Canvas interface just specifies functions that are available on all 
platforms. So I don't think there is a simple way to get the HTML5 canvas 
element from the playn.core.Canvas instance, except doing :

playn.core.Canvas myCanvas = ... ;
CanvasElement element = ((HtmlCanvas) myCanvas).canvas();

But you lose platform independency (the code will only work for the HTML 
backend of PlayN) and you'll also need to modify PlayN HTML project source code 
because the "canvas()" method of the HtmlCanvas class has the package 
visibility (you'll need public instead)

So this is a bad idea IMO

Original comment by mbarbe...@gmail.com on 24 Jan 2012 at 7:48

GoogleCodeExporter commented 9 years ago
One option would be to emulate the Bezier math on platforms that don't have it 
natively, and punt straight through to bezierCurveTo with canvas. I'm not sure 
there is a practical, general solution (i.e., one that balances performance and 
quality) but you could write one for your specific application.

Original comment by pdr@google.com on 24 Jan 2012 at 8:58

GoogleCodeExporter commented 9 years ago

Original comment by samskiv...@gmail.com on 3 Feb 2012 at 10:42