Differences between P5 and PJS: isNaN(), g, try/catch
in
Processing with Other Languages
•
1 year ago
Hi, I've been switching between Processing and ProcessingJS often during the last days and I keep finding differences between them. Maybe you have some ideas about dealing with these:
- isNaN(), a JavaScript function, is Float.isNaN() in Java. Float does not exist in JavaScript. How would you write code that uses isNaN() and is compatible with both? (isNaN stands for "is not a number")
- In Java I can do myPImage.copy(g, ...) to copy from the main canvas into an image. But "g" does not exist in ProcessingJS. Is it doable? Is there a way to write compatible code? Or the only way is using pixels[]?
Try/catch is not documented in the ProcessingJS reference, but it seems to work. I thought I could try to use isNaN and if it fails, catch and use the other isNaN. The funny thing is that Processing (Java) does not let me run something with an error, so I can not even attempt to call isNaN() in the Java version.
1