Cantidad de
círculos:

Cantidad de
círculos por fila:

borde = 0.05 (slider from -5 to 5, step 0.1)
b = 6 (slider from 1 to 20, step 1)
columnas: b
a = 27 (slider from 0 to 70, step 1)
cociente = Div(a, b)
resto = Mod(a, b)
filas: cociente + If[resto ≟ 0, 0, 1]
ancho = Distance(Corner[1], Corner[2])
alto = Distance(Corner[4], Corner[1])
A_4: Corner[4] + (5 * borde * ancho, -borde * alto)
A_2: Corner[2] + (-borde * ancho, borde * alto)
A_1: Corner[1] + (5 * borde * ancho, borde * alto)
sepV: Distance[A_1, A_4] / Max[6, filas]
sepH: Distance[A_1, A_2] / Max[6, columnas]
A_3: Corner[3] + (-borde * ancho, -borde * alto)
polígono1, a_1, a_2, a_3, a_4 = Polygon(A_1, A_2, A_3, A_4)
radio: 0.4 * Min[sepH, sepV]
O: A_1 + (sepH / 2, sepV / 2)
bolas = Sequence(Sequence[Circle[O + (m * sepH, n * sepV), radio], m, 0, b - 1], n, 0, cociente - 1)
bolasresto = Sequence(Circle[O + (m * sepH, cociente * sepV), radio], m, 0, resto - 1)
texto3: "" + b + ""
texto4: "" + a + ""