def tele(maxX, maxY): return randint(0, maxX), randint(0, maxY) if __name__ == "__main__": # y, x, c maxX, maxY = 1920, 1080 img = np.zeros((maxY, maxX, 3), dtype=np.uint8) c = Color(255, 255, 255) x, y = randint(0, maxX), randint(0, maxY) denom = 100 / (maxX * maxY) pixelsWritten = 0 while c.bgr().any() > 0 and pixelsWritten < maxX * maxY: #print("({}+{},{}+{})".format(x,1,y,1)) if (x+1<maxX and img[y,x+1].any() != 0 or not x+1<maxX) \ and (x-1>=0 and img[y, x-1].any() != 0 or not x-1>=0) \ and (y+1<maxY and img[y+1,x].any() != 0 or not y+1<maxY) \ and (y-1>=0 and img[y-1,x].any() != 0 or not y-1>=0): # teleport to a new location #x, y = choice([(a,b) for a in range(maxX) for b in range(maxY) if img[b,a].all() == 0]) # new teleport radR = 1 pointFound = False while x is not None and y is not None and not pointFound: if x + radR >= maxX and y + radR >= maxY and x - radR < 0 and y - radR < 0: x, y = None, None break if y + radR < maxY and not pointFound: