Files
citizen/archive/citizen_blobdetect/citizen_blobdetect.pde

75 lines
1.5 KiB
Plaintext

PImage img_houses;
void setup() {
size(400, 300);
textSize(30);
fill(0);
img_houses = loadImage(dataPath("map/houses_with_borders.png"));
surface.setSize(img_houses.width, img_houses.height);
}
void mousePressed() {
img_houses.loadPixels();
if (int(red(img_houses.pixels[mouseY*img_houses.width+mouseX])) == 187) {
println("clicked on house");
spawnAreas.add(new SpawnArea(mouseX, mouseY));
}
img_houses.updatePixels();
}
ArrayList<SpawnArea> spawnAreas = new ArrayList<SpawnArea>();
class SpawnArea {
//simplified hull?
ArrayList<PVector> v2_points = new ArrayList<PVector>();
SpawnArea(int startX, int startY) {
int x = startX;
int y = startY;
v2_points.add(new PVector(x, y));
//while (int(red(img_houses.pixels[y*img_houses.width+x])) == 187) {
// y++;
// v2_points.add(new PVector(x, y));
// while (int(red(img_houses.pixels[y*img_houses.width+x])) == 187) {
// v2_points.add(new PVector(x, y));
// y++;
// }
// y = startY;
// x++;
//}
//x = startX-1;
//y = startY+1;
//while(int(red(img_houses.pixels[y*img_houses.width+x])) == 187){
// v2_points.add(new PVector(x, y));
// x--;
//}
}
}
void draw() {
background(255);
image(img_houses, 0, 0, img_houses.width, img_houses.height);
for (SpawnArea spawn : spawnAreas) {
for (PVector point : spawn.v2_points) {
point(point.x, point.y);
}
}
text(int(frameRate), 0, 30);
}