misc: Update icon generator and regenerate icon

This commit is contained in:
Daniel S. 2019-09-28 15:42:22 +02:00
parent 66267e72dd
commit 78384801c6
3 changed files with 15 additions and 21 deletions

View File

@ -1,7 +1,7 @@
import svgwrite import svgwrite
import random import random
import time import time
from math import factorial from math import factorial,sin,cos,pi
from itertools import permutations from itertools import permutations
import tsp as m_tsp import tsp as m_tsp
@ -48,7 +48,7 @@ def generate(seed,name=None,small=False):
random.seed(seed) random.seed(seed)
w=2 w=2
max_rings=3 max_rings=3
num_points=10 num_points=5
min_dist=10+10+20*(max_rings+1) min_dist=10+10+20*(max_rings+1)
base_r=10 base_r=10
ring_step=lambda v:10+v*10 ring_step=lambda v:10+v*10
@ -62,17 +62,7 @@ def generate(seed,name=None,small=False):
color="#eee" color="#eee"
pos=make_points(num_points,size,min_dist=min_dist) pos=make_points(num_points,size,min_dist=min_dist)
print("TSP...") print("TSP...")
min_d=float('inf')
for p1 in pos:
for p2 in pos:
if p1==p2:
continue
min_d=min(min_d,dist(p1,p2))
print(min_d,min_dist)
pos=tsp(pos) pos=tsp(pos)
for (x1,y1),(x2,y2) in zip(pos,pos[1:]): for (x1,y1),(x2,y2) in zip(pos,pos[1:]):
if small: if small:
x1/=sd x1/=sd
@ -87,8 +77,6 @@ def generate(seed,name=None,small=False):
base_r=5 base_r=5
px/=sd px/=sd
py/=sd py/=sd
px=svgwrite.px(px)
py=svgwrite.px(py)
if random.random()>0.8: if random.random()>0.8:
dwg.add(dwg.circle((px,py),r=base_r+random.random()*base_r,stroke_width=w,stroke='#0ae')).fill('#0ae') dwg.add(dwg.circle((px,py),r=base_r+random.random()*base_r,stroke_width=w,stroke='#0ae')).fill('#0ae')
else: else:
@ -96,20 +84,26 @@ def generate(seed,name=None,small=False):
r=base_r r=base_r
for _ in range(random.randint(1,max_rings)): for _ in range(random.randint(1,max_rings)):
if small: if small:
random.random()
random.random() random.random()
random.random() random.random()
continue continue
r+=ring_step(random.random()) r+=ring_step(random.random())
ring_col=color
if random.random()>0.75: if random.random()>0.75:
circ=dwg.add(dwg.circle((px,py),r=r,stroke_width=w,stroke="#ea0")) ring_col="#ea0"
else: circ=dwg.add(dwg.circle((px,py),r=r,stroke_width=w,stroke=ring_col))
circ=dwg.add(dwg.circle((px,py),r=r,stroke_width=w,stroke=color))
circ.fill(color,opacity=0) 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() dwg.save()
seed=-4
seed=0
generate(seed,"icon_1",small=False) generate(seed,"icon_1",small=False)
generate(seed,"icon_1_small",small=True) generate(seed,"icon_1_small",small=True)

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@ -1,2 +1,2 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<svg baseProfile="full" height="100%" version="1.1" width="100%" xmlns="http://www.w3.org/2000/svg" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink"><defs><style type="text/css"><![CDATA[.background { fill: #222; }]]></style></defs><rect class="background" height="100%" width="100%" x="0" y="0" /><line stroke="#eee" stroke-width="2" x1="246.10546288126204" x2="262.0282212988338" y1="224.4886007350756" y2="161.17171395434758" /><line stroke="#eee" stroke-width="2" x1="262.0282212988338" x2="230.94964725869315" y1="161.17171395434758" y2="110.82818151973186" /><line stroke="#eee" stroke-width="2" x1="230.94964725869315" x2="172.17482595889732" y1="110.82818151973186" y2="38.51042504100474" /><line stroke="#eee" stroke-width="2" x1="172.17482595889732" x2="140.14289520771126" y1="38.51042504100474" y2="99.72918757324084" /><line stroke="#eee" stroke-width="2" x1="140.14289520771126" x2="35.28570482860707" y1="99.72918757324084" y2="158.39446661633116" /><line stroke="#eee" stroke-width="2" x1="35.28570482860707" x2="105.45946109992596" y1="158.39446661633116" y2="223.95105103930598" /><line stroke="#eee" stroke-width="2" x1="105.45946109992596" x2="154.14923853808895" y1="223.95105103930598" y2="180.8455098637578" /><line stroke="#eee" stroke-width="2" x1="154.14923853808895" x2="154.25244413817927" y1="180.8455098637578" y2="251.32748194291003" /><line stroke="#eee" stroke-width="2" x1="154.25244413817927" x2="262.43656399206003" y1="251.32748194291003" y2="280.6963690094133" /><circle cx="246.10546288126204px" cy="224.4886007350756px" fill="#0ae" r="6.21955438443566" stroke="#0ae" stroke-width="2" /><circle cx="262.0282212988338px" cy="161.17171395434758px" fill="#0ae" r="5.712471969544122" stroke="#0ae" stroke-width="2" /><circle cx="230.94964725869315px" cy="110.82818151973186px" fill="#eee" r="8.532807049334448" stroke="#eee" stroke-width="2" /><circle cx="172.17482595889732px" cy="38.51042504100474px" fill="#eee" r="8.989675096605016" stroke="#eee" stroke-width="2" /><circle cx="140.14289520771126px" cy="99.72918757324084px" fill="#eee" r="8.283296944948145" stroke="#eee" stroke-width="2" /><circle cx="35.28570482860707px" cy="158.39446661633116px" fill="#eee" r="5.401241589269531" stroke="#eee" stroke-width="2" /><circle cx="105.45946109992596px" cy="223.95105103930598px" fill="#0ae" r="9.475194837133376" stroke="#0ae" stroke-width="2" /><circle cx="154.14923853808895px" cy="180.8455098637578px" fill="#0ae" r="6.786837729900069" stroke="#0ae" stroke-width="2" /><circle cx="154.25244413817927px" cy="251.32748194291003px" fill="#eee" r="8.65744610395424" stroke="#eee" stroke-width="2" /><circle cx="262.43656399206003px" cy="280.6963690094133px" fill="#eee" r="7.1306556767192895" stroke="#eee" stroke-width="2" /></svg> <svg baseProfile="full" height="100%" version="1.1" width="100%" xmlns="http://www.w3.org/2000/svg" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink"><defs><style type="text/css"><![CDATA[.background { fill: #222; }]]></style></defs><rect class="background" height="100%" width="100%" x="0" y="0" /><line stroke="#eee" stroke-width="2" x1="94.01202243435863" x2="51.628773919897476" y1="60.79150855767895" y2="135.3977536212687" /><line stroke="#eee" stroke-width="2" x1="51.628773919897476" x2="264.4887607719297" y1="135.3977536212687" y2="235.11308787395214" /><line stroke="#eee" stroke-width="2" x1="264.4887607719297" x2="226.29065062635962" y1="235.11308787395214" y2="90.48204392257941" /><line stroke="#eee" stroke-width="2" x1="226.29065062635962" x2="169.1700020437034" y1="90.48204392257941" y2="104.17066086036256" /><circle cx="94.01202243435863" cy="60.79150855767895" fill="#eee" r="5.53091646215765" stroke="#eee" stroke-width="2" /><circle cx="51.628773919897476" cy="135.3977536212687" fill="#eee" r="6.358738772326545" stroke="#eee" stroke-width="2" /><circle cx="264.4887607719297" cy="235.11308787395214" fill="#0ae" r="9.400253756805997" stroke="#0ae" stroke-width="2" /><circle cx="226.29065062635962" cy="90.48204392257941" fill="#eee" r="6.236611100792434" stroke="#eee" stroke-width="2" /><circle cx="169.1700020437034" cy="104.17066086036256" fill="#eee" r="9.41158619939395" stroke="#eee" stroke-width="2" /></svg>

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB