We are about to switch to a new forum software. Until then we have removed the registration on this forum.
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
(float)
casting.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.
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
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!
If you wanna see some code for both pjs & p5.js versions, take a look at here:
http://Forum.Processing.org/two/discussion/8997/hoppy-beaver
http://Studio.ProcessingTogether.com/sp/pad/export/ro.9bTfM49wCIJza