Further improve layouting
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
s3lph 2022-10-12 03:37:23 +02:00
parent 02fa59a4af
commit 89553cfafa
Signed by: s3lph
GPG key ID: 8AC98A811E5BEFF5
2 changed files with 8 additions and 13 deletions

View file

@ -390,8 +390,7 @@ class BoundingBox:
swm = self.with_margin(pdist)
swe = self.with_margin(ns.dotsize_erfa)
swc = self.with_margin(ns.dotsize_treff)
swme = swm.with_margin(ns.dotsize_erfa)
swmc = swm.with_margin(ns.dotsize_treff)
maxs = []
# I hope these weights are somewhat reasonably balanced...
# Basically the weights correspond to geometrical distances,
# except for an actual collision, which gets a huge extra weight.
@ -406,13 +405,7 @@ class BoundingBox:
w += 50
self._optimal = False
else:
w += max(pdist*2 - swm.chebyshev_distance(o), 0)
continue
if o in swm:
if o.finished:
w += 3
else:
w += 1
maxs.append(max(pdist*2 - swm.chebyshev_distance(o), 0))
for city, location in erfas.items():
if city == self.meta['city']:
continue
@ -420,7 +413,7 @@ class BoundingBox:
w += 1000
self._optimal = False
else:
w += max(pdist*2 - swe.chebyshev_distance(location), 0)
maxs.append(max(pdist*2 - swe.chebyshev_distance(o), 0))
for city, location in chaostreffs.items():
if city == self.meta['city']:
continue
@ -428,7 +421,9 @@ class BoundingBox:
w += 1000
self._optimal = False
else:
w += max(pdist*2 - swc.chebyshev_distance(location), 0)
maxs.append(max(pdist*2 - swc.chebyshev_distance(location), 0))
if len(maxs) > 0:
w += max(maxs)
self._weight = w
@property
@ -490,8 +485,8 @@ def optimize_text_layout(ns, erfas, chaostreffs, size, svg):
BoundingBox(erfax - mw/2, erfay + dist, width=mw, height=mh, meta=meta, base_weight=bw + 0.001),
BoundingBox(erfax - ns.dotsize_erfa, erfay - dist - mh, width=mw, height=mh, meta=meta, base_weight=bw + 0.002),
BoundingBox(erfax - ns.dotsize_erfa, erfay + dist, width=mw, height=mh, meta=meta, base_weight=bw + 0.003),
BoundingBox(erfax + ns.dotsize_erfa - mw, erfay - dist - mh, width=mw, height=mh, meta=meta, base_weight=bw + 0.001),
BoundingBox(erfax + ns.dotsize_erfa - mw, erfay + dist, width=mw, height=mh, meta=meta, base_weight=bw + 0.001),
BoundingBox(erfax + ns.dotsize_erfa - mw, erfay - dist - mh, width=mw, height=mh, meta=meta, base_weight=bw + 0.002),
BoundingBox(erfax + ns.dotsize_erfa - mw, erfay + dist, width=mw, height=mh, meta=meta, base_weight=bw + 0.003),
])
# If debugging is enabled, render one rectangle around each label's bounding box, and one rectangle around each label's median box

Binary file not shown.

Before

Width:  |  Height:  |  Size: 428 KiB

After

Width:  |  Height:  |  Size: 428 KiB