From cbd3fed8b8b1d28da203606711f162af6466013a Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Sat, 5 Apr 2025 15:18:45 -0500 Subject: [PATCH] scripts: *d3.py: Tried to make highlighted graphs more visible These were hard to read, especially in light mode (which I use the least). They're still hard to read, but hopefully a bit less so: - Decreased opacity of unfocused tiles 0.7 -> 0.5 - Don't unfocus unused blocks in dbgbmapd3.py - Softened arrow color in light mode #000000 -> #555555 --- scripts/codemapd3.py | 8 +++++--- scripts/dbgbmapd3.py | 20 +++++++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/scripts/codemapd3.py b/scripts/codemapd3.py index 06c04111..0e99acd2 100755 --- a/scripts/codemapd3.py +++ b/scripts/codemapd3.py @@ -1474,7 +1474,8 @@ def main(paths, output, *, 'markerWidth="6" ' 'markerHeight="6" ' 'orient="auto-start-reverse" ' - 'fill="black">') + 'fill="%(color)s">' % dict( + color='#000000' if dark else '#555555')) f.write('') f.write('') f.write('') @@ -1517,7 +1518,7 @@ def main(paths, output, *, f.write('function draw_unfocus() {') # lower opacity of unfocused tiles f.write( 'for (let b of document.querySelectorAll(".tile")) {') - f.write( 'b.setAttribute("fill-opacity", 0.7);') + f.write( 'b.setAttribute("fill-opacity", 0.5);') f.write( '}') f.write('}') @@ -1557,7 +1558,8 @@ def main(paths, output, *, f.write( 'arrow.setAttribute("y1", a_iy);') f.write( 'arrow.setAttribute("x2", b_ix);') f.write( 'arrow.setAttribute("y2", b_iy);') - f.write( 'arrow.setAttribute("stroke", "black");') + f.write( 'arrow.setAttribute("stroke", "%(color)s");' % dict( + color='#000000' if dark else '#555555')) f.write( 'arrow.setAttribute("marker-end", "url(#arrowhead)");') f.write( 'arrow.setAttribute("pointer-events", "none");') f.write( 'a.parentElement.appendChild(arrow);') diff --git a/scripts/dbgbmapd3.py b/scripts/dbgbmapd3.py index c1c2f66f..0895bc87 100755 --- a/scripts/dbgbmapd3.py +++ b/scripts/dbgbmapd3.py @@ -5019,10 +5019,11 @@ def main(disk, output, mroots=None, *, f.write('' % dict( block=b.block, + type=b.type, x=b.x, y=b.y, js= 'data-block="%(block)d" ' @@ -5092,7 +5093,8 @@ def main(disk, output, mroots=None, *, 'markerWidth="6" ' 'markerHeight="6" ' 'orient="auto-start-reverse" ' - 'fill="black">') + 'fill="%(color)s">' % dict( + color='#000000' if dark else '#555555')) f.write('') f.write('') f.write('') @@ -5140,8 +5142,9 @@ def main(disk, output, mroots=None, *, # our main drawing functions f.write('function draw_unfocus() {') # lower opacity of unfocused tiles - f.write( 'for (let b of document.querySelectorAll(".block")) {') - f.write( 'b.setAttribute("fill-opacity", 0.7);') + f.write( 'for (let b of document.querySelectorAll(' + '".block:not(.unused)")) {') + f.write( 'b.setAttribute("fill-opacity", 0.5);') f.write( '}') f.write('}') @@ -5181,7 +5184,8 @@ def main(disk, output, mroots=None, *, f.write( 'arrow.setAttribute("y1", a_iy);') f.write( 'arrow.setAttribute("x2", b_ix);') f.write( 'arrow.setAttribute("y2", b_iy);') - f.write( 'arrow.setAttribute("stroke", "black");') + f.write( 'arrow.setAttribute("stroke", "%(color)s");' % dict( + color='#000000' if dark else '#555555')) f.write( 'arrow.setAttribute("marker-end", "url(#arrowhead)");') f.write( 'arrow.setAttribute("pointer-events", "none");') f.write( 'a.parentElement.appendChild(arrow);') @@ -5217,7 +5221,8 @@ def main(disk, output, mroots=None, *, f.write( 'arrow.setAttribute("y1", a_iy);') f.write( 'arrow.setAttribute("x2", b_ix);') f.write( 'arrow.setAttribute("y2", b_iy);') - f.write( 'arrow.setAttribute("stroke", "black");') + f.write( 'arrow.setAttribute("stroke", "%(color)s");' % dict( + color='#000000' if dark else '#555555')) f.write( 'arrow.setAttribute("stroke-dasharray", "5,5");') f.write( 'arrow.setAttribute("pointer-events", "none");') f.write( 'a.parentElement.appendChild(arrow);') @@ -5474,7 +5479,8 @@ def main(disk, output, mroots=None, *, f.write( 'arrow.remove();') f.write( '}') # revert opacity - f.write( 'for (let b of document.querySelectorAll(".block")) {') + f.write( 'for (let b of document.querySelectorAll(' + '".block:not(.unused)")) {') f.write( 'b.setAttribute("fill-opacity", 1);') f.write( '}') f.write('}')