We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi all, I made a sketch, kind of a mire poix that ill use for other sketches, I put it on open processing: http://www.openprocessing.org/sketch/206002 in java mode the transition between views is quite smooth but in js its horribly slow, i tried to make it efficient but somehow the framerate is horrendous. I tried to add comments to make the code understandable but making code understandable is not my strong point, sorry...
Answers
i suspect it is in one of these lines but cant figure out why js has so much difficulty with these:
for (int i=0; i < wPixels; i++) { for (int j=0; j < hPixels; j++) { if (animatIng) {
//or this one:
rect((i+1)(width/wPixels), (j+1)(height/hPixels), r(width/wPixels)-1, r(height/hPixels)-1) ;
http://forum.Processing.org/two/discussion/8045/how-to-format-code-and-text
http://forum.Processing.org/two/discussion/11605/100x100-grid-draw-at-2-fps
This ran at an ok speed for me in Java, never tried JavaScript mode. I did some code motion modifications that do not affect the sketch, curious to see if it runs faster in JavaScript mode:
@goToLoop, sorry about the code formatting. Ill look into the fixes you applied in the other topic, thanks for the reply. @asimes, thanks for the code cleanup! it works smoother now in java then it did before so thats nice, It doesnt work properly yet in js so Ill check that also later. Have to work now..
@goToLoop, im sorry but I could not figure out how some of your changes improved the framerate, I did find that drawwing rectangles is tanking the framerate, if I zoom in on the ocean framerate shoots up so somehow the rectangles are killing the framerate. Thanks for the link though! @asimes, thanks again for the refactor, I fixed it so it runs in javascript, (needed two int casting and a modification in the animating loop to make sure the background is not refreshed after animating). script seems smoother then before thanks!
Ah, didn't realize that the int casting could be needed in JavaScript mode but not Java mode (never used Processing's JavaScript mode). Glad the speed up translated into JavaScript mode