# Two questions video.sh cannot ask of a picture that moves. # # Grid scrolls a pixel a frame, so nothing can be asked about a particular pixel: whether # pixel 4 is a grid line depends on which frame this is. Both questions below are true of the # picture whatever the fine scroll offset happens to be. # # grid - is this a grid of one repeated tile? Periodic every eight pixels across, and # not all one colour. # bands - does the attribute nibble recolour each cell row? The colours found in one band # of eight rows differ from those in the next, whatever the ground is doing. import sys data = open(sys.argv[1], "rb").read() fields = data.split(b"\n", 3) width = int(fields[1].split()[0]) body = fields[3] def pixel(x, y): at = (y * width + x) * 3 return tuple(body[at:at + 3]) if sys.argv[2] == "grid": row = [pixel(x, 4) for x in range(32)] periodic = all(row[x] == row[x + 8] for x in range(24)) varied = len(set(row)) > 1 print("yes" if periodic and varied else "not periodic" if not periodic else "all one colour") else: # A band is eight rows, which is one cell row wherever the boundary has slid to. The # ground is the same under every scheme, so what tells them apart is the line colour - # and looking at the whole band finds it without knowing where in the band it is. first = set(pixel(0, y) for y in range(8)) second = set(pixel(0, y) for y in range(8, 16)) print("yes" if first != second else "the same in both: %s" % sorted(first))