from PADS import SVG
import sys
import random
n = 32
k = 15
r = 6
w = 4*n*r
def vertex(i):
return 4*i*r + 2*r + (w//2)*1j
def radius(i,j):
return 2*abs(i-j)*r
planted = set()
while len(planted) < k:
planted.add(random.randrange(n))
svg = SVG.SVG(w+w*1j,sys.stdout)
svg.group(stroke=SVG.colors.black)
svg.group(fill=SVG.colors.none)
for i in range(n):
for j in range(i):
if i in planted and j in planted:
svg.arc(vertex(i),vertex(j),radius(i,j))
elif random.randrange(2):
svg.arc(vertex(j),vertex(i),radius(i,j))
svg.ungroup()
svg.group(fill=SVG.colors.blue)
for i in range(n):
if i in planted:
svg.circle(vertex(i),r)
svg.ungroup()
svg.group(fill=SVG.colors.yellow)
for i in range(n):
if i not in planted:
svg.circle(vertex(i),r)
svg.ungroup()
svg.ungroup()
svg.close()