Skip to content

Instantly share code, notes, and snippets.

@pydsigner
Created October 9, 2012 19:39
Show Gist options
  • Save pydsigner/3860963 to your computer and use it in GitHub Desktop.
Save pydsigner/3860963 to your computer and use it in GitHub Desktop.
Mask to PixList
from pgpu.iter_utils import flatten
def get_set(mask):
xsize, ysize = mask.get_size()
# return a 1D list of all the mask locations that are set
return flatten((((x, y) for y in range(ysize) if mask.get_at((x, y)))
for x in range(xsize)), 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment