Last active
February 24, 2019 02:32
-
-
Save powpingdone/f511ef9e7583393c20c33575a2676528 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from random import randint | |
filename=input("Filename? (dont add .svg)\n") | |
f=open(filename+".svg","w") | |
f.write("<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">") | |
iteration=eval(input("Iterations? (more iterations more randomness)\n")) | |
paths=["C","S","Q","L","H","V"] | |
randmax=randint(200,1000) | |
def gen(path,max): | |
if path=="C": | |
return path+" "+str(randint(1,max))+" "+str(randint(1,max))+", "+str(randint(1,max))+" "+str(randint(1,max))+", "+str(randint(1,max))+" "+str(randint(1,max))+" " | |
elif path=="S" or path=="Q": | |
return path+" "+str(randint(1,max))+" "+str(randint(1,max))+", "+str(randint(1,max))+" "+str(randint(1,max))+" " | |
elif path=="L": | |
return path+" "+str(randint(1,max))+" "+str(randint(1,max))+" " | |
elif path=="H" or path=="V": | |
return path+" "+str(randint(-1*max,max))+" " | |
for x in range(iteration): | |
r,g,b=format(randint(0,255),"02x"),format(randint(0,255),"02x"),format(randint(0,255),"02x") | |
path="M"+str(randint(1,randmax))+","+str(randint(1,randmax)) | |
for x in range(randint(1,25)): | |
path+=str(gen(paths[randint(0,len(paths)-1)],randmax)) | |
path=path+"z" | |
f.write("\n<path fill=\"#"+r+g+b+"\" d=\""+path+"\"/>") | |
f.write("\n</svg>") | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment