2018-08-30 21:49:49 +00:00
|
|
|
import random
|
2018-08-30 22:43:13 +00:00
|
|
|
from datetime import datetime
|
2018-08-30 21:49:49 +00:00
|
|
|
|
2018-08-30 22:43:13 +00:00
|
|
|
def disableCells(cellX,cellY,wsq):
|
|
|
|
|
for y in range(wsq):
|
|
|
|
|
for x in range(wsq):
|
|
|
|
|
cells[cellX+x][cellY+y] = False
|
2018-08-30 21:49:49 +00:00
|
|
|
|
2018-08-30 22:43:13 +00:00
|
|
|
def availSpace(cellX,cellY):
|
|
|
|
|
countX = 0
|
|
|
|
|
countY = 0
|
|
|
|
|
for x in range(cellX,cols):
|
|
|
|
|
if cells[x][cellY]:
|
|
|
|
|
countX +=1
|
|
|
|
|
else:
|
|
|
|
|
break
|
|
|
|
|
for y in range(cellY,rows):
|
|
|
|
|
if cells[cellX][y]:
|
|
|
|
|
countY +=1
|
|
|
|
|
else:
|
|
|
|
|
break
|
|
|
|
|
return min(countX,countY,maxsize)
|
2018-08-30 21:49:49 +00:00
|
|
|
|
2018-08-30 22:43:13 +00:00
|
|
|
size(600,600)
|
|
|
|
|
palette = ['#0d3b66','#faf0ca','#f4d35e','#ee964b','#f95738']
|
|
|
|
|
cols = 60
|
|
|
|
|
rows = 60
|
|
|
|
|
maxsize = 3
|
2018-08-30 21:49:49 +00:00
|
|
|
cells = [[True for x in range(cols)] for y in range(rows)]
|
|
|
|
|
|
|
|
|
|
wsq = width/cols
|
|
|
|
|
hsq = height/rows
|
2018-08-30 22:43:13 +00:00
|
|
|
#noStroke()
|
2018-08-30 21:49:49 +00:00
|
|
|
|
|
|
|
|
for y in range(rows):
|
|
|
|
|
for x in range(cols):
|
|
|
|
|
if cells[x][y]:
|
2018-08-30 22:43:13 +00:00
|
|
|
fill(random.choice(palette))
|
|
|
|
|
sqsize = random.randint(1,availSpace(x,y))
|
|
|
|
|
print(sqsize)
|
|
|
|
|
rect(x*wsq,y*hsq,width/cols * sqsize,height/rows * sqsize)
|
|
|
|
|
disableCells(x,y,sqsize)
|
2018-08-30 21:49:49 +00:00
|
|
|
|
2018-08-30 22:43:13 +00:00
|
|
|
filename = datetime.now().strftime('%Y%m%d%H%M%S.tga')
|
|
|
|
|
#save(filename)
|