Calculations for creating Layouts with columns. Find out how wide your columns or your gutters have to be to fit your layout. If the result isn’t an integer rounded solutions will be provided
from math import * def gutters(cols=3, colwidth=410, fullwidth=1280): _c2(fullwidth, colwidth, cols, True) def cols(cols=3, gutterwidth=25, fullwidth=1280): _c2(fullwidth, gutterwidth, cols, False) def golden(gw=25, fw=1280): c1 = fw/2.618033926 c2 = round(fw-c1-(gw/2)) c1 = round(c1-(gw/2)) print([gw, fw]) print([c1, c2]) def _c(a, b, c, d, z): if z: return (a-(b*c))/d else: return (a-(b*d))/c def _c2(w, x, y, z): y = ceil(y) v = y-1 x_ = x u1 = u2 = _c(w, x, y, v, z) while u1 % 1: x += 1 u1 = _c(w, x, y, v, z) print([y, x, w]) print(u1) if u1 != u2: x = x_ while u2 % 1: x -= 1 u2 = _c(w, x, y, v, z) print([y, x, w]) print(u2)