Add different color printing modes
YE ye YELLOW yellow #FFFF00 #ffff00
This commit is contained in:
parent
c27f8dc825
commit
719ddd1e0d
@ -7,6 +7,8 @@ COLORS_I2C = ('BK', 'RD', 'YE', 'GN')
|
||||
|
||||
PINOUT_SPI_DATAONLY = ('MISO','MOSI','SCK')
|
||||
|
||||
wireviz.color_mode = 'SHORT' # short/SHORT/full/FULL/hex/HEX
|
||||
|
||||
# example 1
|
||||
X1 = wireviz.Node('X1', type='D-Sub', gender='female', pinout=PINOUT_SERIAL, ports_right=True)
|
||||
X2 = wireviz.Node('X2', type='Molex KK 254', gender='female', num_pins=6, ports_left=True)
|
||||
|
||||
@ -2,7 +2,8 @@
|
||||
COLOR_CODE_DIN = ['WH','BN','GN','YE','GY','PK','BU','RD','BK','VT']
|
||||
COLOR_CODE_IEC = ['BN','RD','OG','YE','GN','BU','VT','GY','WH','BK']
|
||||
|
||||
color_dict = {'BK': '#000000',
|
||||
color_hex = {
|
||||
'BK': '#000000',
|
||||
'WH': '#ffffff',
|
||||
'GY': '#808080',
|
||||
'PK': '#ff80c0',
|
||||
@ -16,6 +17,23 @@ color_dict = {'BK': '#000000',
|
||||
'BN': '#666600',
|
||||
}
|
||||
|
||||
color_full = {
|
||||
'BK': 'black',
|
||||
'WH': 'white',
|
||||
'GY': 'grey',
|
||||
'PK': 'pink',
|
||||
'RD': 'red',
|
||||
'OG': 'orange',
|
||||
'YE': 'yellow',
|
||||
'GN': 'green',
|
||||
'TQ': 'turquoise',
|
||||
'BU': 'blue',
|
||||
'VT': 'violet',
|
||||
'BN': 'brown',
|
||||
}
|
||||
|
||||
color_mode = 'SHORT'
|
||||
|
||||
class Node:
|
||||
|
||||
def __init__(self, name, type=None, gender=None, show_name=True, num_pins=None, pinout=None, ports_left=False, ports_right=False):
|
||||
@ -213,6 +231,20 @@ class Cable:
|
||||
else:
|
||||
l = []
|
||||
for i,x in enumerate(self.colors,1):
|
||||
if color_mode == 'full':
|
||||
x = color_full[x].lower()
|
||||
elif color_mode == 'FULL':
|
||||
x = color_hex[x].upper()
|
||||
elif color_mode == 'hex':
|
||||
x = color_hex[x].lower()
|
||||
elif color_mode == 'HEX':
|
||||
x = color_hex[x].upper()
|
||||
elif color_mode == 'short':
|
||||
x = x.lower()
|
||||
elif color_mode == 'SHORT':
|
||||
x = x.upper()
|
||||
else:
|
||||
raise Exception('Unknown color mode')
|
||||
l.append('<w{wireno}>{wirecolor}'.format(wireno=i,wirecolor=x))
|
||||
s = s + '|'.join(l)
|
||||
if self.shield == True:
|
||||
@ -237,8 +269,8 @@ class Cable:
|
||||
s = s + '{'
|
||||
if isinstance(x[2], int):
|
||||
search_color = self.colors[x[2]-1]
|
||||
if search_color in color_dict:
|
||||
s = s + 'edge[color="#000000:{wire_color}:#000000"] '.format(wire_color=color_dict[search_color])
|
||||
if search_color in color_hex:
|
||||
s = s + 'edge[color="#000000:{wire_color}:#000000"] '.format(wire_color=color_hex[search_color])
|
||||
if x[1] is not None:
|
||||
t = '{from_name}:p{from_port} -> {via_name}:w{via_wire}{via_subport}; '.format(from_name=x[0],from_port=x[1],via_name=self.name, via_wire=x[2], via_subport='i' if self.show_pinout == True else '')
|
||||
s = s + t
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user