from PIL import Image image = Image.new('RGB', [380, 380], 255) pixels = image.load() for x in range(image.size[0]): for y in range(image.size[1]): pixels[x, y] = ( x % 255, y % 255, (x**2-y**2) % 255, ) image.show()