Processing | OPENGL | JavaScript mode problem?

edited January 2014 in JavaScript Mode

Hi,

I have some trouble with a few sketches. They work fine in Processing 2. But when I switch to JavaScript mode they do not display. Can someone give me a hint about what could be wrong? You can find the files here:

http://www.loftmatic.com/_pages/Research/GDV/P_1_2_3/GDV_13/P_1_2_3_03_GDV_02.html http://www.loftmatic.com/_pages/Research/GDV/P_1_2_3/GDV_14/P_1_2_3_03_GDV_03.html http://www.loftmatic.com/_pages/Research/GDV/P_1_2_3/GDV_15/P_1_2_3_03_GDV_04.html http://www.loftmatic.com/_pages/Research/GDV/P_1_2_3/GDV_16/P_1_2_3_03_GDV_05.html

Answers

  • Answer ✓

    It appears that you use the java.util.Calendar class, which is not available in JavaScript mode because it is (obviously) part of a Java package. Instead (depending on your usage), you must use either Processing's date / time functions or JavaScript's native date / time functions. This is one example of deviation in JavaScript mode from Java mode.

    Also, I'm not entirely sure what the generativedesign.* package is, but it may have been created for Java mode and, as such, won't work in JavaScript mode. You may have to port it over.

  • Hi,

    Thanks for your answer. I am aware of the fact that the java.util.Calendar class and generativedesign.* library will not work in JavaScript. But I left them in. Otherwise I have to rewrite every program for JavaScript. Now at least the Processing version will work if you download the program. By the way... if you check this page

    http://www.loftmatic.com/_pages/Research/GDV/P_1_2_3.html

    you can see that all other programs work in JavaScript despite that the java.util.Calendar class and generativedesign.* library is used. What I mean is that JavaScript does not complain about them being in the code. Anyway... I will have to live with those constrains I think. I will change the text on that page adding your remark.

  • Answer ✓

    calsign is right, look at the JavaScript console of your browser: "ReferenceError: Calendar is not defined"

    The difference with the other scripts is that the timestamp() function isn't called there (unless you hit the right key), while in http://www.loftmatic.com/_pages/Research/GDV/P_1_2_3/GDV_13/P_1_2_3_03_GDV_02.pde (for example), it is called if savePDF is true, which is the case in your sketch (and don't expect to save to PDF (or other image format) in JS too!).

Sign In or Register to comment.