@gferreira said in Grid:
w = (width() - gutter * (cols + 1)) / cols
h = (height() - gutter * (rows + 1)) / rows
Thank you very much, it worked way much better, I also tried to add a margin feature that worked well so now I can design over the grid
size(1000, 1000)
cols = 3
rows = 3
gutter = 12
#Margin
mTop = 10 - gutter
mBottom = 20 - gutter
mLeft = 10 - gutter
mRight = 10 - gutter
w = (width() - gutter * (cols + 1)) / cols - ((mRight + mLeft) / cols)
h = (height() - gutter * (rows + 1)) / rows - ((mTop + mBottom) / rows)
fill(None)
strokeWidth(1)
stroke(0, 1, 1)
for col in range(cols):
for row in range(rows):
x = gutter + col * (w + gutter)
y = gutter + row * (h + gutter)
rect(x + mLeft, y + mBottom, w, h)