How to use canvas in view?

// Expert user has replied.
M MengChang Xiao 3 years 7 months ago
5 3 0

There is no explanation on how to get DOM object.
Anyone can tell me how to do it?
I want to use canvas in view, I know it is a little strange,but RHO can interact with COMM / bluetooth/camera/light ..., then ,can't access DOM! it is impossible.

Please Register or Login to post a reply

3 Replies

R Robert Galvin

There are a few Canvas.js based JS frameworks out there so you do not have to recreate the wheel.

I have used: Konva - JavaScript 2d canvas framework on numerous projects and it seems to work quite nicely.

P Pietro Francesco Maggi

You can access the DOM from JavaScript as always, putting/including your code in the *.erb files.
It's true that there's no API from Ruby, but this is not what you usually do on the "server side" of a Rhodes application.

~Pietro

J Jon Tara

You can use any native browser (webview) API, including canvas API. You can use native browser APIs or jQuery (assuming you load jQuery) to find DOM objects. Of course, you need to do this in Javascript, you don't have access from Ruby controller, except by using WebView.executeJavascript() to run some JS code. (Probably just call your defined function(s).

Rhodes itself has no specific functionality for canvas or DOM objects, beyond what is offered by the native Javascript APIs and whatever additional Javascript libraries that you load.

Availability will depend on specific device platform. It will be implemented on all modern devices.

Canvas API at MDN:

    Canvas API - Web API Interfaces | MDN

miAudit-ECNC in the RhoMobile App Gallery shows what's possible in a Rhodes app using the canvas.

CONTACT
Can’t find what you’re looking for?