Skip to content

Instantly share code, notes, and snippets.

@brendandawes
Created June 1, 2016 13:44
Show Gist options
  • Select an option

  • Save brendandawes/039d3b90903ef8f01b9baca0c72e7c64 to your computer and use it in GitHub Desktop.

Select an option

Save brendandawes/039d3b90903ef8f01b9baca0c72e7c64 to your computer and use it in GitHub Desktop.
Converts non-white pixels in a black & white image to an ArrayList of PVectors
ArrayList alphaMaskToVectors(String file){
PImage img = loadImage(file);
ArrayList vectors = new ArrayList();
for (int i=0; i < img.width; i++) {
for (int j=0; j < img.height; j++) {
color c = img.get(i,j);
if (red(c) != 255 && green(c) != 255 && blue(c) != 255) {
vectors.add(new PVector(i,j));
}
}
}
return vectors;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment