Because of reasons I don't understand (I have almost no experience with PJS), the pix
variable, which is declared as an int
, can sometimes be something that isn't an int
in your code. When I inserted println(pix + ":" + r+","+g+","+b);
at the bottom of the colorRetriever
method, I got a bunch of numbers like this:
7401.5:8,255,3
7431.5:15,255,4
7461.500000000001:0,0,0
7491.499999999999:0,0,0
7521.5:26,255,35
7551.5:34,255,38
7581.499999999998:0,0,0
7611.500000000001:0,0,0
7641.499999999999:0,0,0
7671.500000000002:0,0,0
7701.5:39,255,20
7731.5:25,255,23
7761.500000000001:0,0,0
7791.499999999999:0,0,0
And when using these floats as an index to the array, instead of crashing, it just returned zero. I'm not really sure why that's how JS deals with non-integer indexing. And I'm also not sure why an int can have decimal points. Anyways, I hope that helps.
Side note: In the course of my investigation, I learned that you can't resize() an image that you loaded from a different server, for some reason the browser doesn't allow it. If you can't draw an image after resizing it, perhaps that's why.