In [7]:
import matplotlib.image as image
import numpy as np
from PIL import Image
color = [0,0,0]
filas, columnas = 200, 200
n = 8
nI = filas/n
nJ = columnas/n
img = np.ones((filas, columnas, 3))
def pintar(img,x0,x1,y0,y1,color):
for x in range(int(x0),int(x1)):
for y in range(int(y0),int(y1)):
img[x][y] = np.array(color)
imagenes = []
for i in range(n):
for j in range(n):
if (i+j)%2==1:
pintar(img,i*nI,(i+1)*nI,j*nJ,(j+1)*nJ,color)
imagenes.append(Image.fromarray(np.uint8(img*255)))
im = Image.fromarray(np.uint8(img*255))
imagenes[0].save('gif/ajedrez.gif',
save_all=True,
append_images=imagenes[1:],
optimize=False,
duration=500,
loop=0)
im
Out[7]:
No hay comentarios.:
Publicar un comentario