8000 Fixed color issues · ZombyDogs/spatialmath-python@6d768b4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6d768b4

Browse files
committed
Fixed color issues
1 parent f63e4ec commit 6d768b4

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

spatialmath/super_pose.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@
1818
_color = True
1919
#print('using colored output')
2020
except ImportError:
21+
#print('colored not found')
2122
_color = False
22-
def fg(): return ''
23-
def bg(): return ''
24-
def attr(): return ''
23+
2524

2625
# try:
2726
# import colorama
@@ -498,10 +497,18 @@ def __repr__(self):
498497
# return str.rstrip("\n") # Remove trailing newline character
499498
# else:
500499
# raise ValueError('no elements in the value list')
501-
return self.__str__()
500+
return self._st 8000 ring(color=_color)
502501

503502
def __str__(self):
503+
return self._string(color=False)
504+
505+
def _string(self, color=False):
504506
#print('in __str__')
507+
508+
FG = lambda c: fg(c) if color else ''
509+
BG = lambda c: bg(c) if color else ''
510+
ATTR = lambda c: attr(c) if color else ''
511+
505512
def mformat(self, X):
506513
# X is an ndarray value to be display
507514
# self provides set type for formatting
@@ -518,15 +525,15 @@ def mformat(self, X):
518525
if rownum < n:
519526
if colnum < n:
520527
# rotation part
521-
s = fg('red') + bg('grey_93') + s + attr(0)
528+
s = FG('red') + BG('grey_93') + s + ATTR(0)
522529
else:
523530
# translation part
524-
s = fg('blue') + bg('grey_93') + s + attr(0)
531+
s = FG('blue') + BG('grey_93') + s + ATTR(0)
525532
else:
526533
# bottom row
527-
s = fg('grey_50') + bg('grey_93') + s + attr(0)
534+
s = FG('grey_50') + BG('grey_93') + s + ATTR(0)
528535
rowstr += s
529-
out += rowstr + bg('grey_93') + ' ' + attr(0) + '\n'
536+
out += rowstr + BG('grey_93') + ' ' + ATTR(0) + '\n'
530537
return out
531538

532539
output_str = ''

0 commit comments

Comments
 (0)
0