From 8bd77de3206aea90db2630e837f363b8c710561f Mon Sep 17 00:00:00 2001 From: Yohann Dedy Date: Thu, 30 Aug 2018 23:49:49 +0200 Subject: [PATCH] =?UTF-8?q?Carr=C3=A9s=20de=2020x20=20pixels=20al=C3=A9ato?= =?UTF-8?q?irement=20noir=20ou=20blancs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- randomSquares.pyde | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 randomSquares.pyde 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)