Fine-tune multicolor wire PR

- Remove modified background color -> should be discusses as a separate feature
- Render shields as thin tinned wire with black border, safer for b&w priting than single light-gray line
- Remove PE as color definition, since it is not, and should be called with GNYE
- Clean up minor things
This commit is contained in:
Daniel Rojas 2020-07-18 12:28:52 +02:00
parent c94d3eed0e
commit 3732597ded
3 changed files with 20 additions and 46 deletions

View File

@ -1,4 +1,5 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import os
from setuptools import setup, find_packages

View File

@ -67,7 +67,7 @@ class Harness:
font = 'arial'
dot.attr('graph', rankdir='LR',
ranksep='2',
bgcolor=wv_colors.default_bknd_color,
bgcolor='white',
nodesep='0.33',
fontname=font)
dot.attr('node', shape='record',
@ -204,7 +204,6 @@ class Harness:
html = f'{html}<td>{bla}</td>'
html = f'{html}</tr>'
bgcolors = ['#000000'] + get_color_hex(connection_color) + ['#000000']
html = f'{html}<tr><td colspan="{len(p)}" border="0" cellspacing="0" cellpadding="0" port="w{i}" height="{(2 * len(bgcolors))}"><table cellspacing="0" cellborder="0" border = "0">'
for j, bgcolor in enumerate(bgcolors[::-1]): # Reverse to match the curved wires when more than 2 colors
@ -225,7 +224,6 @@ class Harness:
for attrib in wireidentification:
html = f'{html}<td>{attrib}</td>'
html = f'{html}</tr></table></td></tr>'
# html = html + '</table></td></tr>'
if cable.shield:
p = ['<!-- s_in -->', 'Shield', '<!-- s_out -->']
@ -252,8 +250,8 @@ class Harness:
if isinstance(connection_color.via_port, int): # check if it's an actual wire and not a shield
dot.attr('edge', color=':'.join(['#000000'] + wv_colors.get_color_hex(cable.colors[connection_color.via_port - 1]) + ['#000000']))
else: # it's a shield connection
dot.attr('edge', color='#000000')
# shield is shown as a thin tinned wire
dot.attr('edge', color=':'.join(['#000000', wv_colors.get_color_hex('SN')[0], '#000000']))
if connection_color.from_port is not None: # connect to left
from_ferrule = self.connectors[connection_color.from_name].category == 'ferrule'
port = f':p{connection_color.from_port}r' if not from_ferrule else ''

View File

@ -1,5 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
COLOR_CODES = {
@ -22,15 +23,8 @@ COLOR_CODES = {
'T568B': ['WHOG', 'OG', 'WHGN', 'BU', 'WHBU', 'GN', 'WHBN', 'BN'],
}
default_color = '#ffffff'
# default_bkgnd_color = '#ffffff' # white
default_bknd_color = '#fffbf8' # off-white beige-ish
# Convention: Color names should be 2 letters long, to allow for multicolored wires
shield_color = '#aaaaaa' # Tinned wire
_color_hex = {
'BK': '#000000',
'WH': '#ffffff',
@ -45,16 +39,10 @@ _color_hex = {
'VT': '#8000ff',
'BN': '#895956',
'SL': '#708090',
# Faux-copper look, for bare CU wire
'CU': '#d6775e',
# Silvery look for tinned bare wire
'SN': '#aaaaaa',
# Darker silver for silvered wire
'AG': '#84878c',
# Golden color for gold
'AU': '#ffcf80',
# Yellow-green PE wire (matching actual wire colors, should prevent confusion with a yellow-green dual color wire
'PE': '#54aa85:#f7f854:#54aa85',
'CU': '#d6775e', # Faux-copper look, for bare CU wire
'SN': '#aaaaaa', # Silvery look for tinned bare wire
'AG': '#84878c', # Darker silver for silvered wire
'AU': '#ffcf80', # Golden color for gold
}
_color_full = {
@ -75,10 +63,8 @@ _color_full = {
'SN': 'tinned copper',
'AG': 'silver wire',
'AU': 'gold wire',
'PE': 'earth'
}
# TODO Help wanted: can someone check the german translation?
_color_ger = {
'BK': 'sw',
'WH': 'ws',
@ -92,28 +78,20 @@ _color_ger = {
'BU': 'bl',
'VT': 'vi',
'BN': 'br',
# To the best of my ability, likely incorrect:
# Slate --> Schieferfarbe --> SI ??
'SL': 'si',
# Copper
'CU': 'cu',
# Tinned
'SN': 'sn',
# Silver
'AG': 'ag',
# Gold
'AU': 'au',
# Earth
'PE': 'pe'
'SL': 'si', # Slate/Schiefer?
'CU': 'ku', # Copper/Kupfer
'SN': 'vz', # Tinned/verzinkt
'AG': 'ag', # Silver
'AU': 'au', # Gold
}
color_default = '#ffffff'
def get_color_hex(input, pad=True):
if input is None or input == '':
# print('Unspecified color requested', file=sys.stderr)
return [default_color]
return [color_default]
if len(input) == 4: # give wires with EXACTLY 2 colors that striped/banded look
input = input + input[:2]
# hacky style fix: give single color wires a triple-up so that wires are the same size
@ -122,16 +100,14 @@ def get_color_hex(input, pad=True):
try:
output = [_color_hex[input[i:i + 2]] for i in range(0, len(input), 2)]
except KeyError:
print("Unknown Color Specified", file=sys.stderr)
output = [default_color]
# raise Exception('Unknown Color Name')
print("Unknown color specified")
output = [color_default]
return output
def translate_color(input, color_mode):
if input == '' or input is None:
# print('Unspecified color requested', file=sys.stderr)
return default_color
return color_default
upper = color_mode.isupper()
if not (color_mode.isupper() or color_mode.islower()):
raise Exception('Unknown color mode capitalization')
@ -151,4 +127,3 @@ def translate_color(input, color_mode):
return output.upper()
else:
return output.lower()