improved balloon customisation

This commit is contained in:
Mattias Andrée 2012-08-21 15:03:34 +02:00
parent 1524a8d07b
commit ef624440a8

22
ponysay
View file

@ -722,11 +722,6 @@ class Balloon():
if w < minw: w = minw if w < minw: w = minw
if h < minh: h = minh if h < minh: h = minh
rc = []
for j in range(0, len(self.n)):
rc.append(self.nw[j] + self.n[j] * (w - len(self.nw[j]) - len(self.ne[j])) + self.ne[j])
if len(lines) > 1: if len(lines) > 1:
(ws, es) = ({0 : self.nww, len(lines) - 1 : self.sww}, {0 : self.nee, len(lines) - 1 : self.see}) (ws, es) = ({0 : self.nww, len(lines) - 1 : self.sww}, {0 : self.nee, len(lines) - 1 : self.see})
for j in range(1, len(lines) - 1): for j in range(1, len(lines) - 1):
@ -735,11 +730,26 @@ class Balloon():
else: else:
(ws, es) = ({0 : self.ww}, {0 : self.ee}) (ws, es) = ({0 : self.ww}, {0 : self.ee})
rc = []
for j in range(0, len(self.n)):
outer = len(self.nw[j]) + len(self.ne[j])
inner = len(self.nnw[j]) + len(self.nne[j])
if outer + inner >= w:
rc.append(self.nw[j] + self.nnw[j] + self.n[j] * (w - outer - inner) + self.nne[j] + self.ne[j])
else:
rc.append(self.nw[j] + self.n[j] * (w - outer) + self.ne[j])
for j in range(0, len(lines)): for j in range(0, len(lines)):
rc.append(ws[j] + lines[j] + ' ' * (w - lencalc(lines[j]) - len(self.w) - len(self.e)) + es[j]) rc.append(ws[j] + lines[j] + ' ' * (w - lencalc(lines[j]) - len(self.w) - len(self.e)) + es[j])
for j in range(0, len(self.s)): for j in range(0, len(self.s)):
rc.append(self.sw[j] + self.s[j] * (w - len(self.sw[j]) - len(self.se[j])) + self.se[j]) outer = len(self.sw[j]) + len(self.se[j])
inner = len(self.ssw[j]) + len(self.sse[j])
if outer + inner >= w:
rc.append(self.sw[j] + self.ssw[j] + self.s[j] * (w - outer - inner) + self.sse[j] + self.se[j])
else:
rc.append(self.sw[j] + self.s[j] * (w - outer) + self.se[j])
return '\n'.join(rc) return '\n'.join(rc)