PNG Pixels with Motion Algorithm
in
Programming Questions
•
2 years ago
Hi to all,
I have this question and I am struggling to find an approach, but I can't find any so far. If someone has a solution, please share it with me.
So, I have this simple code that extracts from a .png image only the pixels that are not transparent, and then draws points every 5 pixels with color taken from that specific area of the image. So far so good, no harm caused.
However, I would like to be able to control the position of each point with motion algorithms based on interaction with the user (i.e. the points start moving when the mouse is closer). How can I control ONLY the points that are drawn from the image - lets assume there are just 200 points that have been created and I want each one to be controlled by the motion algorithms?
Any thoughts?
PImage myPic;
int cell = 5;
void setup() {
size(600,450);
frameRate(30);
myPic = loadImage("afu.png");
myPic.resize(width, height);
smooth();
}
void draw() {
background(0);
fill(255,10);
rect(0,0,width,height);
for(int x=cell; x < width; x+=cell) {
for(int y=cell; y < height; y+=cell) {
color myColor = myPic.get(x,y);
float alphaCol = brightness(myPic.pixels[x + (y * width)]);
stroke(myColor, alphaCol);
strokeWeight(3);
//Here I want to attached the values of the motion algorithm but I can't find a way to initialize and attach values
//properly
point(x, y);
}
}
}
1