Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a color list for breakpoints #59

Merged
merged 3 commits into from
Sep 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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