SVGWrite Environment

This notebook creates a reusable environment with SVGWrite.

pip install svgwrite
4.8s
SVGWrite (Bash)
import math
import random
import svgwrite
dots, c, size, w, h = 3000, 6.1, 4, 670, 150
phi = (1 + math.sqrt(5)) / 2
rad_phi = (math.pi * 2) / (phi + 1)
dwg = svgwrite.Drawing("/results/spiral.svg", (w, h))
a = 0
for n in range (0, dots):
  r = c * math.sqrt(n)
  x = r * math.cos (a) + w / 2
  y = r * math.sin (a) + h / 2
  color = "#%06x" % random.randint(0, 0xFFFFFF)
  dwg.add(dwg.circle ((x, y), size, fill=color))
  a += rad_phi
dwg.save()
0.9s
Python
SVGWrite
Runtimes (2)