Loading...
Logo
Processing Forum

copy() not working?

in General Discussion  •  Other  •  1 month ago  
Since upgrading to Processing 2, I have noticed that copy() seems to be really stubborn about working or not.

In several different sketches I have tried using it to copy a section from one image and draw to the main window and it doesn't copy anything.

For example I have 8 images and I want a strip from each, in one sketch it is working OK but in another it is not, copying nothing or occasionally just one strip?!

It seems to be better if it is in a separate function to draw() and using OPENGL renderer.

Has anyone else noticed this or am I going mad?

Cheers

Replies(2)

There are several versions of copy(), so it is hard to answer...
I rarely used this function in my sketches, and never without a PGraphics parameter.

I saw a recent topic mentioning an issue with copy(), but the shown code was not working in 1.5.1 either... And it worked when I added this PGraphics parameter!

Perhaps the main issue appears when you try to copy something from the sketch area, inside the same draw() frame: if the drawings are not yet rendered, then there is nothing to copy.

Showing a simple sketch reproducing your problems might help in pinpointing the error, or in making a bug report.
Thanks, I think what you are saying sounds about right, I've got it working much better since moving it to a function outside the draw loop. If the problem crops up again then I will do a thorough test. I'm sure it's down to some sloppy programming by me somewhere down the line!