I’ve been having problems plotting points using getImageData and setImageData. Specifically, it sometimes works, but for no apparent reason, sometimes it doesn’t. For example, consider the following code :
createCanvas(“1”, 320, 450);
setFillColor(“black”);
rect(0, 0, 320, 450);
…
setStrokeColor(rgb(xcurrent * reddelta, greendelta * i, (450 - ycurrent) * bluedelta));
//Plot a point
line(xcurrent, ycurrent, xcurrent, ycurrent);
The above works. But, If I replace the above with the equivalent imageData code :
createCanvas(“1”, 320, 450);
setFillColor(“black”);
rect(0, 0, 320, 450);
var Sieveimage = getImageData(0, 0, 320, 450);
…
setRGB(Sieveimage, xcurrent, ycurrent, xcurrent * reddelta, greendelta * i, (450 - ycurrent) * bluedelta, 255);
…
putImageData(Sieveimage, 0, 0);
The above does not work – nothing ever gets displayed on the screen.
I’ve written code that works fine with imageData but for some reason it’s not working now.
Might anyone know what the problem is? Any help would be greatly appreciated.
Thanks,
jdb2