Is processing.js supposed to support 3.0?

edited August 2015 in JavaScript Mode

Greetings.

The following code (sorry, some variable names are in Finnish for Finnish readers) produces a nice little picture in Processing 3.0 beta 4. However, when I "feed" it to processing.js on a web page, I only get one thin red line. My other processing.js figures work perfectly, but they are all Processing 2 code.

I am not really up to date with the development of Processing 3. Is processing.js supposed to support 3.0? So is this a bug or just waiting for future work?

 final int LEVEYS = 800;
 final int KORKEUS = 100;
 final int YLAMARGINAALI = 50;
 final int VARI_MAX = 100;
 final int SATURAATIOT_N = 20; // oletetaan, että leveys jaollinen tällä

 final int SATURAATIO_ASKEL = LEVEYS / SATURAATIOT_N;

 void settings ()
 {
   size (LEVEYS, KORKEUS);
 }

 void setup ()
 {
   background (255);
   fill (0);
   colorMode (HSB, VARI_MAX);
   textSize (.3 * YLAMARGINAALI);
   textAlign (CENTER, TOP);
 }

 void draw ()
 {
   for (int i = 0; i < LEVEYS; i++)
   {
     float saturaatio = ((float) i) / (LEVEYS - 1) * VARI_MAX;
     stroke (saturaatio, VARI_MAX, VARI_MAX);
     line (i, YLAMARGINAALI, i, KORKEUS);

     if (i == 0 || i % SATURAATIO_ASKEL == 0 || i == LEVEYS - 1)
     {
       String str = "";
       text (str.format ("%.0f", saturaatio), i, 0);
     }
   }
 }

Answers

  • edited August 2015 Answer ✓
    • ProcessingJS (JPS) a.K.a JavaScript Mode, stopped in time!
    • Even though it's supposed to be compatible w/ latest Processing versions in theory...
    • ... in practice it's not even on par w/ Processing 2, but a much older Processing 1.5.1! @-)
    • New band-aid callback settings() doesn't work in Processing 2, much less in PJS!
    • And I doubt String's format() would be recognizable too.
    • Tip: Java automatically coerce whole datatypes into fractional 1s. No need for (float) casting.
    • Besides, all numbers in JS are double float precision after all. :-\"
  • GoToLoop,

    interesting. So there are probably no plans to make processing.js support 3.0. I noticed that p5.js is being developed... Is there some other ongoing work to support the embedding of Processing code in web pages?

    As for the (float), I also thought automatic conversion would take place, but if you try that code without the cast it doesn't work, at least not in the Linux version. So I added the cast there. Maybe I should report it.

  • edited August 2015 Answer ✓

    ... but if you try that code without the cast it doesn't work, ...

    • Sorry, I didn't pay attention enough that was a division operation there! X_X
    • If both operands are of whole type, any fraction value part is removed from result! #-o
    • In this specific case, we gotta make at least 1 of the operands a floating type so the division result is what we expect. ~O)

    Is there some other ongoing work to support the embedding of Processing code in web pages?

    Well, currently I'm refactoring PVector class in order to reach parity w/ Processing 3:
    https://GitHub.com/processing-js/processing-js/issues/200
    https://GitHub.com/processing-js/processing-js/pull/201

    It's not much, but I plan to add more tidbits later... 8-X

    I noticed that p5.js is being developed...

    Indeed, Processing Foundation officially abandoned Processing.JS (PJS) in favor of p5.js! X(

  • And of course there seem to be some differences between Processing and p5.js, so you can not export code directly... So for now I will be using processing.js with whatever it supports. Thanks!

  • edited August 2015
Sign In or Register to comment.