#!/usr/bin/env python2 # make an svg that shows a circular text where each letter is 'networked' to the others # (c) roel roscam abbing 2018 # gplv3 import random, svgwrite from math import sin, cos, pi #place text in circle w = 400 h = 400 doc = svgwrite.Drawing(filename = "circle.svg", size = ("{}px".format(w), "{}px".format(h))) font = '/home/r/.local/share/fonts/Unknown Vendor/OpenType/Grundschrift/Grundschrift_Regular.otf' radius = 150 word = 'constellation' letterpoints=[] letterpoints2 =[] text = svgwrite.container.Group(style="font-family:Arima Koshi;font-size:60px;fill:salmon;") for i,letter in enumerate(word): x = sin((-pi*2)/len(word)*i+pi)*radius y = cos((-pi*2)/len(word)*i+pi)*radius # x = 15*i l = doc.text(letter,insert=(x+w/2, y+w/2)) l2 = doc.text(letter,style='fill:snow;',insert=(x+w/2.02, y+w/2.02)) letterpoints.append(l) text.add(l) text.add(l2) connections = svgwrite.container.Group(style="fill:none;stroke:salmon;stroke-width:2px;stroke-dasharray:4px;stroke-opacity:0.2;stroke-linecap:round;") for i in range(len(letterpoints)*2): points = random.sample(letterpoints,2) line = doc.line( start=(points[0].attribs['x'],points[0].attribs['y']), end=(points[1].attribs['x'],points[1].attribs['y']) ) connections.add(line) doc.add(connections) doc.add(text) doc.save() # # for l in letterpoints: # # l.draw = True # bot.finish()