def deform_pixel(self, node):
        for neighbor in self.pixel_graph.neighbors(node):
            if node[0] == neighbor[0] or node[1] == neighbor[1]:
                # We only care about diagonals.
                continue
            px_x = max(neighbor[0], node[0])
            px_y = max(neighbor[1], node[1])
            pixnode = (px_x, px_y)
            offset_x = neighbor[0] - node[0]
            offset_y = neighbor[1] - node[1]
            # There's probably a better way to do this.
            adj_node = (neighbor[0], node[1])
            if not self.match(node, adj_node):
                pn = (px_x, px_y - offset_y)
                mpn = (px_x, px_y - 0.5 * offset_y)
                npn = (px_x + 0.25 * offset_x, px_y - 0.25 * offset_y)
                remove_from_set(self.pixel_corners(adj_node), pixnode)
                self.pixel_corners(adj_node).add(npn)
                self.pixel_corners(node).add(npn)
                self._deform(pixnode, pn, mpn, npn)
            adj_node = (node[0], neighbor[1])
            if not self.match(node, adj_node):
                pn = (px_x - offset_x, px_y)
                mpn = (px_x - 0.5 * offset_x, px_y)
                npn = (px_x - 0.25 * offset_x, px_y + 0.25 * offset_y)
                remove_from_set(self.pixel_corners(adj_node), pixnode)
                self.pixel_corners(adj_node).add(npn)
                self.pixel_corners(node).add(npn)
                self._deform(pixnode, pn, mpn, npn)
Deform an individual pixel.
dataset/ETHPy150Open jerith/depixel/depixel/depixeler.py/PixelData.deform_pixel