commit 8bd77de3206aea90db2630e837f363b8c710561f Author: Yohann Dedy Date: Thu Aug 30 23:49:49 2018 +0200 Carrés de 20x20 pixels aléatoirement noir ou blancs diff --git a/randomSquares.pyde b/randomSquares.pyde new file mode 100644 index 0000000..93d8d21 --- /dev/null +++ b/randomSquares.pyde @@ -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)