I tried to create some random points inside a boundary defined by color (RGB(100,100,100)). If each new point's relating pixel is RGB(100,100,100), then create the point; vice versa. However, I find it really hard to work with this array. anybody has an suggestion?
PImage b;
PImage c;
float envSize = 280;
int population = 1000;
color[] imgPixels = new color[parseInt(envSize*2)*parseInt(envSize)];
kVec strPt;
//setup
void setup() {
smooth();
b = loadImage("background.gif");
size(b.width,b.height,P3D);
c = loadImage("boundary.png");
image(c,-width/2,-height/2);
loadPixels();
for(int i = 0; i < envSize*2*envSize; i++){
imgPixels[i] = pixels[i];
}
for(int i = 0; i < population; i++) {
strPt = new kVec(random(0,envSize),random(0,envSize/2),random(0,envSize/3));
colorMode(RGB);
if(pixels[parseInt(strPt.y)* width + parseInt(strPt.x)] == color(100,100,100)){
//create the point here;
}
}
}
PImage b;
PImage c;
float envSize = 280;
int population = 1000;
color[] imgPixels = new color[parseInt(envSize*2)*parseInt(envSize)];
kVec strPt;
//setup
void setup() {
smooth();
b = loadImage("background.gif");
size(b.width,b.height,P3D);
c = loadImage("boundary.png");
image(c,-width/2,-height/2);
loadPixels();
for(int i = 0; i < envSize*2*envSize; i++){
imgPixels[i] = pixels[i];
}
for(int i = 0; i < population; i++) {
strPt = new kVec(random(0,envSize),random(0,envSize/2),random(0,envSize/3));
colorMode(RGB);
if(pixels[parseInt(strPt.y)* width + parseInt(strPt.x)] == color(100,100,100)){
//create the point here;
}
}
}
1