Skip to content

Commit

Permalink
display origin/size in hex
Browse files Browse the repository at this point in the history
  • Loading branch information
cracked-machine committed Feb 4, 2024
1 parent e318862 commit 91b29c0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
4 changes: 2 additions & 2 deletions mmdiagram/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ def _create_diagram(self, region_list: List[mmdiagram.types.Region]):
# add origin text for the region
text_img = PIL.Image.new("RGB", (30, 10), color=(255, 255, 0))
text_canvas = PIL.ImageDraw.Draw(text_img)
text_canvas.text((0, 0), str(region.origin), fill="black")
text_canvas.text((0, 0), str(region._origin), fill="black")
text_img = text_img.rotate(180)
img_main.paste(text_img, (0, region.origin))

# horizontal flip and write to file
img_main = img_main.rotate(180)

Expand Down
14 changes: 6 additions & 8 deletions mmdiagram/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(self, name: str, origin: str, size: str):
self.name: str = name
"""region legend"""
self._origin: str = origin
"""memory address"""
"""region address as hex"""
self._size: str = size
"""size in bytes"""
self.colour = self._pick_available_colour()
Expand All @@ -28,24 +28,22 @@ def __init__(self, name: str, origin: str, size: str):
# and we don't want duplicate colours in our diagram
if "lightslategray" in Region._remaining_colours:
del Region._remaining_colours["lightslategray"]

@property
def origin(self):
"""get region address as integer"""
return int(self._origin, 16)

@origin.setter
def origin(self, val):
self._origin = val

@property
def size(self):
"""get region size as integer"""
return int(self._size, 16)

def __str__(self):
return "|"\
+ "<span style='color:" + str(self.colour) + "'>" + str(self.name) + "</span>|"\
+ str(self.origin) + "|"\
+ str(self.size) + "|"\
+ str(self._origin) + "|"\
+ str(self._size) + "|"\
+ str(self.remain) + "|"

def _pick_available_colour(self):
Expand Down

0 comments on commit 91b29c0

Please sign in to comment.