Better handling for avoiding obstacles when layouting text with 0 distance
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
aa842979e9
commit
7c954242eb
1 changed files with 7 additions and 7 deletions
|
@ -348,9 +348,9 @@ class BoundingBox:
|
|||
else:
|
||||
raise TypeError()
|
||||
|
||||
def compute_weight(self, other, erfas, chaostreffs, ns):
|
||||
def compute_weight(self, other, erfas, chaostreffs, pdist, ns):
|
||||
w = 0
|
||||
swm = self.with_margin(ns.font_distance)
|
||||
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)
|
||||
|
@ -365,7 +365,7 @@ class BoundingBox:
|
|||
else:
|
||||
w += 50
|
||||
else:
|
||||
w += max(ns.font_distance*2 - swc.chebyshev_distance(o), 0)
|
||||
w += max(pdist*2 - swc.chebyshev_distance(o), 0)
|
||||
continue
|
||||
if o in swm:
|
||||
if o.finished:
|
||||
|
@ -378,14 +378,14 @@ class BoundingBox:
|
|||
if location in swe:
|
||||
w += 1000
|
||||
else:
|
||||
w += max(ns.font_distance*2 - swe.chebyshev_distance(location), 0)
|
||||
w += max(pdist*2 - swe.chebyshev_distance(location), 0)
|
||||
for city, location in chaostreffs.items():
|
||||
if city == self.meta['city']:
|
||||
continue
|
||||
if location in swc:
|
||||
w += 1000
|
||||
else:
|
||||
w += max(ns.font_distance*2 - swc.chebyshev_distance(location), 0)
|
||||
w += max(pdist*2 - swc.chebyshev_distance(location), 0)
|
||||
self._weight = w
|
||||
|
||||
@property
|
||||
|
@ -465,7 +465,7 @@ def optimize_text_layout(ns, erfas, chaostreffs, size, svg):
|
|||
all_boxes.update(candidates[city])
|
||||
unfinished_boxes.update(candidates[city])
|
||||
for box in all_boxes:
|
||||
box.compute_weight(all_boxes, erfas, chaostreffs, ns)
|
||||
box.compute_weight(all_boxes, erfas, chaostreffs, pdist=max(ns.font_distance, xheight), ns=ns)
|
||||
|
||||
# Get candidate with the least number of optimal solutions > 0
|
||||
optcity = min(unfinished, key=lambda city: len([1 for box in candidates[city] if box.is_optimal]) or float('inf'))
|
||||
|
@ -491,7 +491,7 @@ def optimize_text_layout(ns, erfas, chaostreffs, size, svg):
|
|||
for city in order:
|
||||
all_boxes = set(finished.values())
|
||||
for box in candidates[city]:
|
||||
box.compute_weight(all_boxes, erfas, chaostreffs, ns)
|
||||
box.compute_weight(all_boxes, erfas, chaostreffs, pdist=max(ns.font_distance, xheight), ns=ns)
|
||||
minbox = min(candidates[city], key=lambda box: box.weight)
|
||||
if minbox is not finished[city]:
|
||||
changed = True
|
||||
|
|
Loading…
Reference in a new issue