Confirmed users
656
edits
Line 129: | Line 129: | ||
Processing.js is compatible with Processing, but is not, and will never be, fully compatible with Java. If your sketch uses functions or classes not defined as part of Processing, they are unlikely to work with Processing.js. Similarly, libraries that are written for Processing, which are written in Java instead of Processing, will most likely not work. | Processing.js is compatible with Processing, but is not, and will never be, fully compatible with Java. If your sketch uses functions or classes not defined as part of Processing, they are unlikely to work with Processing.js. Similarly, libraries that are written for Processing, which are written in Java instead of Processing, will most likely not work. | ||
===Division which is expected to produce an integer might need explicit casting=== | |||
There are a class of bugs that arise when converting Processing code to Processing.js that involve integer vs. floating point division. What was straight-up integer division in Processing code, when converted to Processing.js, can sometimes become problematic, as numbers become doubles, and introduce a fractional part. The fix is to explicitly cast any division to an integer that exhibits this behaviour: | |||
<pre> | |||
// before | |||
int g = mouseX / i; | |||
// after | |||
int g = (int) mouseX / i; | |||
</pre> | |||
===Processing.js has to cheat to simulate Processing's synchronous I/O=== | ===Processing.js has to cheat to simulate Processing's synchronous I/O=== |