import svgwrite import random import time from math import factorial,sin,cos,pi from itertools import permutations import tsp as m_tsp def dist(p1,p2): return dist2(p1,p2)**0.5 def dist2(p1,p2): diff=0 for a,b in zip(p1,p2): diff+=(a-b)**2 return diff def tsp(points): res=[] for idx in m_tsp.tsp(points)[1]: res.append(points[idx]) return res def make_points(n,size,min_dist=0): min_dist*=min_dist points=[] while len(points)0.8: dwg.add(dwg.circle((px,py),r=base_r+random.random()*base_r,stroke_width=w,stroke='#0ae')).fill('#0ae') else: dwg.add(dwg.circle((px,py),r=base_r+random.random()*base_r,stroke_width=w,stroke=color)).fill(color) r=base_r for _ in range(random.randint(1,max_rings)): if small: random.random() random.random() random.random() continue r+=ring_step(random.random()) ring_col=color if random.random()>0.75: ring_col="#ea0" circ=dwg.add(dwg.circle((px,py),r=r,stroke_width=w,stroke=ring_col)) circ.fill(color,opacity=0) d=random.random()*pi*2 dx=cos(d) dy=sin(d) m=random.random() moon=dwg.add(dwg.circle((px+dx*r,py+dy*r),r=2+2*m,stroke_width=w,stroke=ring_col)) moon.fill(ring_col) dwg.save() seed=-4 generate(seed,"icon_1",small=False) generate(seed,"icon_1_small",small=True)