@ti.kernel
def copy_back_and_clear(img: np.ndarray):
    for i in range(res[0]):
        for j in range(res[1]):
            coord = (((((res[1] - 1) - j) * res[0]) + i) * 3)
            for c in ti.static(range(3)):
                img[(coord + c)] = screen[(i, j)][(2 - c)]
                screen[(i, j)][(2 - c)] = 0
@ti.kernel
def copy_back_and_clear(img: np.ndarray):
    for i in range(res[0]):
        for j in range(res[1]):
            coord = (((((res[1] - 1) - j) * res[0]) + i) * 3)
            for c in ti.static(range(3)):
                img[(coord + c)] = screen[(i, j)][(2 - c)]
                screen[(i, j)][(2 - c)] = 0