@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)
Until there's a new feature for this, I think you could replace your newPage() calls to a custom newPageWithBleed() that goes something like this, and wouldn't need to change any of your other drawing code —
def newPageWithBleed(w, h, bleed):
newPage(w + bleed * 2, h + bleed * 2)
translate(bleed, bleed)
W, H = 400, 400
bleed = 25
newPage(W, H)
rect(0, 0, 20, 20)
newPageWithBleed(W, H, bleed)
rect(0, 0, 20, 20)