We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm new to the forum and fairly new to Processing. I've scoured around and founds lots of help so far, but now I'm at a point where I'm not totally sure where to head.
I'd like to load an image, analyze each pixel's RGB value, and based on those values move particles in a certain direction.
So... a little pseudo code to explain my thoughts.
Load image, get it's pixels Go through each pixel, separate it's RGB values If R < 128, velocity.x = -1 If R > 128, velocity.x = 1 If G < 128, velocity.y = -1 If G > 128, velocity.y = 1 Ignore the B values, I don't really need them. position.add(speed) to move the particle.
Initially I was going using the get() function so each particle feeds it's position, looks at the color behind it, analyzes it, and moves accordingly, but that's waaaaay to slow for hundreds of particles.
I'm thinking of loading all of the pixel values into an array (does it need to be a 2D array, for x and y values?) at the start so it's all in memory, and then each particle reads where it's at on the screen, finds the corresponding image pixel index, and just pulls the vector out, without having to re-analyze the image on every frame since it's not changing.
I've been working with vectors for a bit, but I don't have much experience with arrays. Is this a good approach? Can anyone point me in the right direction?