Carrés de 20x20 pixels aléatoirement noir ou blancs
commit
8bd77de320
|
|
@ -0,0 +1,27 @@
|
|||
import random
|
||||
|
||||
size(600,600)
|
||||
|
||||
cols = 30
|
||||
rows = 30
|
||||
|
||||
cells = [[True for x in range(cols)] for y in range(rows)]
|
||||
|
||||
wsq = width/cols
|
||||
hsq = height/rows
|
||||
noStroke()
|
||||
|
||||
for y in range(rows):
|
||||
for x in range(cols):
|
||||
cells[x][y] = bool(random.getrandbits(1))
|
||||
|
||||
|
||||
for y in range(rows):
|
||||
for x in range(cols):
|
||||
if cells[x][y]:
|
||||
fill(255)
|
||||
else:
|
||||
fill(0)
|
||||
rect(x*wsq,y*hsq,width/cols,height/rows)
|
||||
|
||||
print(cells)
|
||||
Loading…
Reference in New Issue