Skip to content

Instantly share code, notes, and snippets.

@impiaaa
Created November 6, 2017 03:48
Show Gist options
  • Save impiaaa/c5e1fda2e49b7f0a4f1dabfbf6ebf91d to your computer and use it in GitHub Desktop.
Save impiaaa/c5e1fda2e49b7f0a4f1dabfbf6ebf91d to your computer and use it in GitHub Desktop.
import re, random, sys, os
def randrepl(matchobj):
if "matrix" in s[matchobj.start()-30:matchobj.start()]: return matchobj.group(0)
v = float(matchobj.group(2))
v = random.gauss(v, 0.1)
return matchobj.group(1)+"%.3f"%v
pat = re.compile("([, (])(-?[0-9]+(\.[0-9]+)?)")
s = open(sys.argv[1]).read()
for i in range(200):
s = pat.sub(randrepl, s)
open("%s-%03d.svg"%(os.path.splitext(sys.argv[1])[0], i), 'w').write(s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment