Skip to content

Commit

Permalink
Merge pull request #59 from yihuajack/breakpoint-color
Browse files Browse the repository at this point in the history
Add a color list for breakpoints
  • Loading branch information
yihuajack committed Sep 11, 2022
2 parents 67fb346 + f9804cf commit ad5f3c2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
10 changes: 7 additions & 3 deletions sootty/visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ class Default:
LINE_COLOR_Z = "#FFFF00"
LINE_COLOR_X = "#FF0000"
LINE_COLOR_DATA = "#3DB8B8"
BREAKPOINT_COLOR = "#FFFF00"
BREAKPOINT_COLOR_LIST = ["#FFFF00"]
TEXT_COLOR = "#FFFFFF"
BKGD_COLOR = "#000000"
# wires going from 0 and 1 are two different colors, x variable is red rectangle, z variable is yellow
# breakpoints: Han Purple, Orange, Erin, Electric Purple, Aqua, Tart Orange, Gainsboro, Slimy Green, Yellow Pantone

class Dark(Default):
pass
Expand All @@ -55,6 +56,9 @@ class Silicon(Default):
# BKGD_COLOR = "#003000"
BKGD_COLOR = "#2b5e2b"

class Colorful(Default):
BREAKPOINT_COLOR_LIST = ["#2829FF", "#FF8314", "#48FF45", "#C200DD", "#26F0F6", "#FF3D3B", "#E1E1E1", "#1A9D1F", "#FDE12D"]

class Debug(Default):
pass

Expand Down Expand Up @@ -175,7 +179,7 @@ def _timestamps_to_svg(self, left, top, start, length):
def _breakpoints_to_svg(self, breakpoints, left, top, start, length, height):
"""Convert a list of breakpoint times to highlights on the svg."""
svg = ""
for index in breakpoints:
for i, index in enumerate(breakpoints):
if index >= start and index < start + length:
svg += self._shape_to_svg(
{
Expand All @@ -186,7 +190,7 @@ def _breakpoints_to_svg(self, breakpoints, left, top, start, length, height):
"y": top,
"width": (self.style.FULL_WIDTH / length),
"height": height,
"fill": self.style.BREAKPOINT_COLOR,
"fill": self.style.BREAKPOINT_COLOR_LIST[i % len(self.style.BREAKPOINT_COLOR_LIST)],
"fill-opacity": 0.4,
}
)
Expand Down
9 changes: 5 additions & 4 deletions tests/test_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@


def test_style_class():

wiretrace = WireTrace.from_vcd("example/example1.vcd")

Visualizer(Style.Silicon).to_svg(wiretrace, start=0, length=8).display()
Visualizer(Style.Silicon).to_svg(wiretrace, start=0, length=8, breakpoints=[4, 5]).display()

Visualizer(Style.Dark).to_svg(wiretrace, start=0, length=8, breakpoints=[4, 5]).display()

Visualizer(Style.Dark).to_svg(wiretrace, start=0, length=8).display()
Visualizer(Style.Light).to_svg(wiretrace, start=0, length=8, breakpoints=[4, 5]).display()

Visualizer(Style.Light).to_svg(wiretrace, start=0, length=8).display()
Visualizer(Style.Colorful).to_svg(wiretrace, start=0, length=8, breakpoints=[4, 5]).display()


if __name__ == "__main__":
Expand Down

0 comments on commit ad5f3c2

Please sign in to comment.