@frederik @justvanrossum Here's the final code with a fully working test. The code defines a design space with 45 shapes (some of which are subsets of larger shapes). The code draws each shape, then draws each unique pair of shapes whose members don't 'touch' and don't overlap.
from itertools import combinations
canvasX = 750
canvasY = canvasX * 1.25
u = (canvasX/50)
def c1():
c = BezierPath()
c.oval(-8 * u - (9 * u), -8 * u, 16 * u, 16 * u)
ch = BezierPath()
ch.oval(-7 * u - (9 * u), -7 * u, 14 * u, 14 * u)
ch.closePath()
c = c.difference(ch)
c.closePath()
return c
def c1t():
c = BezierPath()
c.oval(-8 * u - (9 * u), -8 * u, 16 * u, 16 * u)
ch = BezierPath()
ch.oval(-7 * u - (9 * u), -7 * u, 14 * u, 14 * u)
ch.closePath()
c = c.difference(ch)
r = BezierPath()
r.rect(-8 * u - (9 * u), -8 * u, 16 * u, 8 * u)
c = c.difference(r)
c.closePath()
return c
def c1ti():
c = BezierPath()
c.oval(-8 * u - (9 * u), -8 * u + (7 * u), 16 * u, 16 * u)
ch = BezierPath()
ch.oval(-7 * u - (9 * u), -7 * u + (7 * u), 14 * u, 14 * u)
ch.closePath()
c = c.difference(ch)
r = BezierPath()
r.rect(-8 * u - (9 * u), 7 * u, 16 * u, 8 * u)
c = c.difference(r)
c.closePath()
return c
def c1b():
c = BezierPath()
c.oval(-8 * u - (9 * u), -8 * u, 16 * u, 16 * u)
ch = BezierPath()
ch.oval(-7 * u - (9 * u), -7 * u, 14 * u, 14 * u)
ch.closePath()
c = c.difference(ch)
r = BezierPath()
r.rect(-8 * u - (9 * u), 0, 16 * u, 8 * u)
c = c.difference(r)
c.closePath()
return c
def c1bi():
c = BezierPath()
c.oval(-8 * u - (9 * u), -8 * u - (7 * u), 16 * u, 16 * u)
ch = BezierPath()
ch.oval(-7 * u - (9 * u), -7 * u - (7 * u), 14 * u, 14 * u)
ch.closePath()
c = c.difference(ch)
r = BezierPath()
r.rect(-8 * u - (9 * u), -8 * u - (7 * u), 16 * u, 8 * u)
c = c.difference(r)
c.closePath()
return c
def c1r():
c = BezierPath()
c.oval(-8 * u - (9 * u), -8 * u, 16 * u, 16 * u)
ch = BezierPath()
ch.oval(-7 * u - (9 * u), -7 * u, 14 * u, 14 * u)
ch.closePath()
c = c.difference(ch)
r = BezierPath()
r.rect(-8 * u - (9 * u), -8 * u, 8 * u, 16 * u)
c = c.difference(r)
c.closePath()
return c
def c1l():
c = BezierPath()
c.oval(-8 * u - (9 * u), -8 * u, 16 * u, 16 * u)
ch = BezierPath()
ch.oval(-7 * u - (9 * u), -7 * u, 14 * u, 14 * u)
ch.closePath()
c = c.difference(ch)
r = BezierPath()
r.rect(-(9 * u), -8 * u, 8 * u, 16 * u)
c = c.difference(r)
c.closePath()
return c
def c2():
c = BezierPath()
c.oval(-8 * u, -8 * u, 16 * u, 16 * u)
ch = BezierPath()
ch.oval(-7 * u, -7 * u, 14 * u, 14 * u)
ch.closePath()
c = c.difference(ch)
c.closePath()
return c
def c2t():
c = BezierPath()
c.oval(-8 * u, -8 * u, 16 * u, 16 * u)
ch = BezierPath()
ch.oval(-7 * u, -7 * u, 14 * u, 14 * u)
ch.closePath()
c = c.difference(ch)
r = BezierPath()
r.rect(-8 * u, -8 * u, 16 * u, 8.5 * u)
c = c.difference(r)
c.closePath()
return c
def c2ti():
c = BezierPath()
c.oval(-8 * u, -8 * u + (7 * u), 16 * u, 16 * u)
ch = BezierPath()
ch.oval(-7 * u, -7 * u + (7 * u), 14 * u, 14 * u)
ch.closePath()
c = c.difference(ch)
r = BezierPath()
r.rect(-8 * u, 7 * u, 16 * u, 8 * u)
c = c.difference(r)
c.closePath()
return c
def c2b():
c = BezierPath()
c.oval(-8 * u, -8 * u, 16 * u, 16 * u)
ch = BezierPath()
ch.oval(-7 * u, -7 * u, 14 * u, 14 * u)
ch.closePath()
c = c.difference(ch)
r = BezierPath()
r.rect(-8 * u, -.5 * u, 16 * u, 8.5 * u)
c = c.difference(r)
c.closePath()
return c
def c2bi():
c = BezierPath()
c.oval(-8 * u, -8 * u - (7 * u), 16 * u, 16 * u)
ch = BezierPath()
ch.oval(-7 * u, -7 * u - (7 * u), 14 * u, 14 * u)
ch.closePath()
c = c.difference(ch)
r = BezierPath()
r.rect(-8 * u, -8 * u - (7 * u), 16 * u, 8 * u)
c = c.difference(r)
c.closePath()
return c
def c2r():
c = BezierPath()
c.oval(-8 * u, -8 * u, 16 * u, 16 * u)
ch = BezierPath()
ch.oval(-7 * u, -7 * u, 14 * u, 14 * u)
ch.closePath()
c = c.difference(ch)
r = BezierPath()
r.rect(-8 * u, -8 * u, 8 * u, 16 * u)
c = c.difference(r)
c.closePath()
return c
def c2l():
c = BezierPath()
c.oval(-8 * u, -8 * u, 16 * u, 16 * u)
ch = BezierPath()
ch.oval(-7 * u, -7 * u, 14 * u, 14 * u)
ch.closePath()
c = c.difference(ch)
r = BezierPath()
r.rect(0, -8 * u, 8 * u, 16 * u)
c = c.difference(r)
c.closePath()
return c
def c3():
c = BezierPath()
c.oval(-8 * u + (9 * u), -8 * u, 16 * u, 16 * u)
ch = BezierPath()
ch.oval(-7 * u + (9 * u), -7 * u, 14 * u, 14 * u)
ch.closePath()
c = c.difference(ch)
c.closePath()
return c
def c3t():
c = BezierPath()
c.oval(-8 * u + (9 * u), -8 * u, 16 * u, 16 * u)
ch = BezierPath()
ch.oval(-7 * u + (9 * u), -7 * u, 14 * u, 14 * u)
ch.closePath()
c = c.difference(ch)
r = BezierPath()
r.rect(-8 * u + (9 * u), -8 * u, 16 * u, 8 * u)
c = c.difference(r)
c.closePath()
return c
def c3ti():
c = BezierPath()
c.oval(-8 * u + (9 * u), -8 * u + (7 * u), 16 * u, 16 * u)
ch = BezierPath()
ch.oval(-7 * u + (9 * u), -7 * u + (7 * u), 14 * u, 14 * u)
ch.closePath()
c = c.difference(ch)
r = BezierPath()
r.rect(-8 * u + (9 * u), 7 * u, 16 * u, 8 * u)
c = c.difference(r)
c.closePath()
return c
def c3b():
c = BezierPath()
c.oval(-8 * u + (9 * u), -8 * u, 16 * u, 16 * u)
ch = BezierPath()
ch.oval(-7 * u + (9 * u), -7 * u, 14 * u, 14 * u)
ch.closePath()
c = c.difference(ch)
r = BezierPath()
r.rect(-8 * u + (9 * u), 0, 16 * u, 8 * u)
c = c.difference(r)
c.closePath()
return c
def c3bi():
c = BezierPath()
c.oval(-8 * u + (9 * u), -8 * u - (7 * u), 16 * u, 16 * u)
ch = BezierPath()
ch.oval(-7 * u + (9 * u), -7 * u - (7 * u), 14 * u, 14 * u)
ch.closePath()
c = c.difference(ch)
r = BezierPath()
r.rect(-8 * u + (9 * u), -8 * u - (7 * u), 16 * u, 8 * u)
c = c.difference(r)
c.closePath()
return c
def c3r():
c = BezierPath()
c.oval(-8 * u + (9 * u), -8 * u, 16 * u, 16 * u)
ch = BezierPath()
ch.oval(-7 * u + (9 * u), -7 * u, 14 * u, 14 * u)
ch.closePath()
c = c.difference(ch)
r = BezierPath()
r.rect(-8 * u + (9 * u), -8 * u, 8 * u, 16 * u)
c = c.difference(r)
c.closePath()
return c
def c3l():
c = BezierPath()
c.oval(-8 * u + (9 * u), -8 * u, 16 * u, 16 * u)
ch = BezierPath()
ch.oval(-7 * u + (9 * u), -7 * u, 14 * u, 14 * u)
ch.closePath()
c = c.difference(ch)
r = BezierPath()
r.rect(9 * u, -8 * u, 8 * u, 16 * u)
c = c.difference(r)
c.closePath()
return c
def c4():
c = BezierPath()
c.oval(-8 * u, -8 * u - (17 * u), 16 * u, 16 * u)
ch = BezierPath()
ch.oval(-7 * u, -7 * u - (17 * u), 14 * u, 14 * u)
ch.closePath()
c = c.difference(ch)
c.closePath()
return c
def c4t():
c = BezierPath()
c.oval(-8 * u, -8 * u - (17 * u), 16 * u, 16 * u)
ch = BezierPath()
ch.oval(-7 * u, -7 * u - (17 * u), 14 * u, 14 * u)
ch.closePath()
c = c.difference(ch)
r = BezierPath()
r.rect(-8 * u, -8 * u - (17 * u), 16 * u, 8 * u)
c = c.difference(r)
c.closePath()
return c
def c4b():
c = BezierPath()
c.oval(-8 * u, -8 * u - (17 * u), 16 * u, 16 * u)
ch = BezierPath()
ch.oval(-7 * u, -7 * u - (17 * u), 14 * u, 14 * u)
ch.closePath()
c = c.difference(ch)
r = BezierPath()
r.rect(-8 * u, -(17 * u), 16 * u, 8 * u)
c = c.difference(r)
c.closePath()
return c
def c4r():
c = BezierPath()
c.oval(-8 * u, -8 * u - (17 * u), 16 * u, 16 * u)
ch = BezierPath()
ch.oval(-7 * u, -7 * u - (17 * u), 14 * u, 14 * u)
ch.closePath()
c = c.difference(ch)
r = BezierPath()
r.rect(-8 * u, -8 * u - (17 * u), 8 * u, 16 * u)
c = c.difference(r)
c.closePath()
return c
def c4l():
c = BezierPath()
c.oval(-8 * u, -8 * u - (17 * u), 16 * u, 16 * u)
ch = BezierPath()
ch.oval(-7 * u, -7 * u - (17 * u), 14 * u, 14 * u)
ch.closePath()
c = c.difference(ch)
r = BezierPath()
r.rect(0, -8 * u - (17 * u), 8 * u, 16 * u)
c = c.difference(r)
c.closePath()
return c
"""
def c5(): #may not be needed
c = BezierPath()
c.oval(-8 * u, -8 * u + (17 * u), 16 * u, 16 * u)
ch = BezierPath()
ch.oval(-7 * u, -7 * u + (17 * u), 14 * u, 14 * u)
ch.closePath()
c = c.difference(ch)
c.closePath()
return c
"""
def b1m():
b = BezierPath()
b.rect(-12 * u, -7 * u, u, 14 * u)
b.closePath()
return b
def b1t():
b = BezierPath()
b.rect(-12 * u, -7 * u, u, 22 * u)
b.closePath()
return b
def b1b():
b = BezierPath()
b.rect(-12 * u, -15 * u, u, 22 * u)
b.closePath()
return b
def b2m():
b = BezierPath()
b.rect(-u/2, -7 * u, u, 14 * u)
b.closePath()
return b
def b2t():
b = BezierPath()
b.rect(-u/2, -7 * u, u, 22 * u)
b.closePath()
return b
def b2b():
b = BezierPath()
b.rect(-u/2, -15 * u, u, 22 * u)
b.closePath()
return b
def b3m():
b = BezierPath()
b.rect(11 * u, -7 * u, u, 14 * u)
b.closePath()
return b
def b3t():
b = BezierPath()
b.rect(11 * u, -7 * u, u, 22 * u)
b.closePath()
return b
def b3b():
b = BezierPath()
b.rect(11 * u, -15 * u, u, 22 * u)
b.closePath()
return b
def b4r():
b = BezierPath()
b.rect(0, -u/2, 8 * u, u)
b.closePath()
return b
def b4l():
b = BezierPath()
b.rect(-8 * u, -u/2, 8 * u, u)
b.closePath()
return b
def b5():
b = BezierPath()
b.rect(-8 * u, 9 * u, 16 * u, u)
b.closePath()
return b
def b6():
b = BezierPath()
b.rect(-8 * u, -10 * u, 16 * u, u)
b.closePath()
return b
def a1():
a = BezierPath()
a.moveTo((-9 * u, 7 * u))
a.lineTo((-9 * u + (12.7017059 * u), -15 * u))
a.lineTo((
-9 * u + (12.7017059 * u) - (u * cos(radians(30))),
-15 * u - (u * sin(radians(30)))
))
a.lineTo((
-9 * u - (u * cos(radians(30))),
7 * u - (u * sin(radians(30)))
))
a.closePath()
return a
def a1s():
a = BezierPath()
a.moveTo((-9 * u, 7 * u))
a.lineTo((-9 * u + (8.0829037 * u), -7 * u))
a.lineTo((
-9 * u + (8.0829037 * u) - (u * cos(radians(30))),
-7 * u - (u * sin(radians(30)))
))
a.lineTo((
-9 * u - (u * cos(radians(30))),
7 * u - (u * sin(radians(30)))
))
a.closePath()
return a
def a1si():
a = BezierPath()
a.moveTo((-9 * u, -7 * u))
a.lineTo((-9 * u + (8.0829037 * u), 7 * u))
a.lineTo((
-9 * u + (8.0829037 * u) - (u * cos(radians(30))),
7 * u + (u * sin(radians(30)))
))
a.lineTo((
-9 * u - (u * cos(radians(30))),
-7 * u + (u * sin(radians(30)))
))
a.closePath()
return a
def a2():
a = BezierPath()
a.moveTo((9 * u, 7 * u))
a.lineTo((9 * u - (12.7017059 * u), -15 * u))
a.lineTo((
9 * u - (12.7017059 * u) + (u * cos(radians(30))),
-15 * u - (u * sin(radians(30)))
))
a.lineTo((
9 * u + (u * cos(radians(30))),
7 * u - (u * sin(radians(30)))
))
a.closePath()
return a
def a2s():
a = BezierPath()
a.moveTo((9 * u, 7 * u))
a.lineTo((9 * u - (8.0829037 * u), -7 * u))
a.lineTo((
9 * u - (8.0829037 * u) + (u * cos(radians(30))),
-7 * u - (u * sin(radians(30)))
))
a.lineTo((
9 * u + (u * cos(radians(30))),
7 * u - (u * sin(radians(30)))
))
a.closePath()
return a
def a2si():
a = BezierPath()
a.moveTo((9 * u, -7 * u))
a.lineTo((9 * u - (8.0829037 * u), 7 * u))
a.lineTo((
9 * u - (8.0829037 * u) + (u * cos(radians(30))),
7 * u + (u * sin(radians(30)))
))
a.lineTo((
9 * u + (u * cos(radians(30))),
-7 * u + (u * sin(radians(30)))
))
a.closePath()
return a
matrix = [c1, c1t, c1ti, c1b, c1bi, c1r, c1l, c2, c2t, c2ti, c2b, c2bi, c2r, c2l, c3, c3t, c3ti, c3b, c3bi, c3r, c3l, c4, c4t, c4b, c4r, c4l, b1m, b1t, b1b, b2m, b2t, b2b, b3m, b3t, b3b, b4r, b4l, b5, b6, a1, a1s, a1si, a2, a2s, a2si]
pairs = []
def compareShape(s1, s2):
s1n = s1.copy()
s1n.translate(0, 1)
s1s = s1.copy()
s1s.translate(0, -1)
s1e = s1.copy()
s1e.translate(1, 0)
s1w = s1.copy()
s1w.translate(-1, 0)
if len(set(s1.points) & set(s2.points)) == 0 and len(s1.intersectionPoints(s2)) == 0 and len(s1n.intersectionPoints(s2)) == 0 and len(s1s.intersectionPoints(s2)) == 0 and len(s1e.intersectionPoints(s2)) == 0 and len(s1w.intersectionPoints(s2)) == 0:
newPage(canvasX, canvasY)
frameDuration(1/3)
fill(1)
rect(0, 0, canvasX, canvasY)
translate(canvasX/2, canvasY/2)
fill(0, .05)
for l in range(len(matrix)):
mat = BezierPath()
mat = matrix[l]()
drawPath(mat)
fill(0)
drawPath(s1)
drawPath(s2)
for m in range(len(matrix)):
newPage(canvasX, canvasY)
frameDuration(1/3)
fill(1)
rect(0, 0, canvasX, canvasY)
translate(canvasX/2, canvasY/2)
fill(0, .05)
for l in range(len(matrix)):
mat = BezierPath()
mat = matrix[l]()
drawPath(mat)
fill(0)
single = BezierPath()
single = matrix[m]()
drawPath(single)
for subset in combinations(matrix, 2):
pairs.append(subset)
for n in range(len(pairs)):
compareShape(pairs[n][0](), pairs[n][1]())
#saveImage('~/Desktop/gürtler_script_matrix.pdf')