We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm a new user to processing (but an experienced developer). For various reasons related to teaching programming concepts to new students, I'm actually just using the processing libraries inside IntelliJ and have everything working just fine, or so I thought :-)
One of my colleagues who had just been using the Processing IDE had a simple example where they were loading an image inside the setup() method as follows:
size(400, 400); img = loadImage("cat.jpg");//load image image(img, 0,0);
and indeed the image would be drawn.
However, the same thing does not work if we run this directly as a Java program and in particular, the call "image(img, 0, 0)" has to be inside the draw() method rather than the setup() method.
Now, that actually wasn't a surprise to me and indeed in the online documentation for PImage it's quite clear that the call SHOULD be inside the draw() method. My recommendation to my colleague is to do it right and put the call in draw()!
However, I'm still curious as to why it works in the setup() in processing but not in Java. I noted that if I don't include an @Override version of draw() but put a call to draw() at the end of the setup() method, the image does draw, although very pixelated.
There must be some extra behind-the-scenes stuff going on. I looked for some calls for explicitly redrawing/repainting (found redraw() which didn't seem to do anything).
I realize there's an ANTLR preprocessor involved and perhaps some extra code is being injected into the end of the setup() method.
Thanks in advance.