my code(pde) won't work on web

edited July 2014 in JavaScript Mode

Hi,

I am not sure why my code is not working on web. It works if I run on ide.

Here is the folder on web: http://fkkcloud.com/code/sph/

and to the html: http://fkkcloud.com/code/sph/sph.html

What would be the reason..?

Tagged:

Answers

  • edited July 2014

    Have you at least tried "JavaScript Mode" before hosting your app?
    Know that "Java Mode" conversion to "JavaScript Mode" is limited to Processing's API found in its reference:
    http://ProcessingJS.org/reference/
    And know that 3rd-party Java libraries won't work in "JS Mode" either!
    Also read these PJS tips: http://processingjs.org/articles/p5QuickStart.html

  • _vk_vk
    edited July 2014

    Sometimes browser's debugging tools can give you a good hint, your page throws this issue in my browser:

    [Error] ReferenceError: Can't find variable: Maxim (undefined, line 22)

    As GoToLopp said:

    And know that 3rd-party Java libraries won't work in "JS Mode" either!

  • Also, in JavaScript mode, when you load a image you put that at the beggining of your program: /*@pjs preload = "filename.jpg";*/

  • I am a bit confused. So, I wrote everything in Java mode with Java language. When I change mode to JavaScript, should I actually change some code inside..?

  • The javaScript mode make no changes to your written code.

    And as GoToLoop said

    Also read these PJS tips: http://processingjs.org/articles/p5QuickStart.html

    there are some differences...

    read specially:

    http://processingjs.org/articles/p5QuickStart.html#thingstoknowusingpjs

    Also, what is in red in processingjs reference page, is not implemented.

  • ProcessingJS reads Processing code and attempts to translate its instructions to JavaScript. It does a fairly good job, but it knows only the base Processing functions and data exposed in the Language Reference page. And, as pointed out, not even all of it.

    But at the core, Processing is written in Java, so it can call Java libraries. And it can uses Processing libraries, packaged in external archives. All of this is totally unknown of ProcessingJS: it has just no knowledge of these libraries.

    So, you can run only pure Processing sketches in JS mode. If you have an import statement in your code, you are pretty sure it won't run in JS mode.

  • edited July 2014

    Addendum: There are some rare libraries which are cross-language for Java-JS Modes! (*)

    For example Guido & ijeomamotion:
    https://github.com/fjenett/Guido
    http://ekeneijeoma.com/processing/ijeomamotion/

    Actually, there are both Java & JavaScript versions for each of them.
    However, they share the same API. That is, all method names are the same for both versions!

    A huge pity there ain't much cross-mode libs yet! :o3
    Even JavaScript Mode is being abandoned by the devs in favor of a true JS style right now! /:)
    Although I doubt Processing's target group would cope w/ a JS prototypal "class" approach! (:|
    Rather, IMO, I think CoffeeScript Mode, or who knows a future Dart Mode, would be much easier! :-?

    Nevertheless, I've found out that Java's Date class shares almost the same API as JS's! L-)
    Although Date isn't supported by Processing, it works pretty well as a cross-mode API! Check it out: :))
    http://studio.processingtogether.com/sp/pad/export/ro.9to4yV59zus7B/latest

  • So what would be a good recommendation if I just want to my code to work on web just as it is?

    Does it have to be translated to JS anyway?

    I feel good that this forum is very active. :)>-

  • I'd go w/ "CoffeeScript Mode". Since it has access to all JS libraries and has a class model more in line w/ Java's!

Sign In or Register to comment.