Skip to content

Commit

Permalink
Fix: Bar size calcs w/radius
Browse files Browse the repository at this point in the history
  • Loading branch information
dev committed Aug 22, 2024
1 parent f203eb7 commit 5ca6356
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions scripts/lndchannelbalance.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __init__(self):
self._defaultattr("nodes", [{}])
self._defaultattr("pageSize", 8)
self._defaultattr("watermarkAnchor", "bottom")

# Initialize
super().__init__(name="lndchannelbalance")

Expand Down Expand Up @@ -166,7 +166,9 @@ def run(self):
# local balance is filled portion
percentage = float(local_balance)/float(capacity)
barWidth = int(float(self.width - aliasWidth - outlineWidth) * percentage)
self.draw.rounded_rectangle(xy=(aliasWidth + outlineWidth, dataRowTop + dataRowPadding + outlineWidth, aliasWidth + outlineWidth + barWidth, dataRowBottom - outlineWidth), radius=3, fill=ImageColor.getrgb(self.barFilledColor))
radius = 2
if barWidth < radius: barWidth = radius
self.draw.rounded_rectangle(xy=(aliasWidth + outlineWidth, dataRowTop + dataRowPadding + outlineWidth, aliasWidth + outlineWidth + barWidth, dataRowBottom - outlineWidth), radius=radius, fill=ImageColor.getrgb(self.barFilledColor))
# labels
if self.displayBalancesEnabled:
vicarioustext.drawlefttext(self.draw, str(local_balance), nodeFontSize, aliasWidth+outlineWidth+1, dataRowTop + (dataRowHeight//2) + outlineWidth + 1, ImageColor.getrgb(self.backgroundColor))
Expand Down

0 comments on commit 5ca6356

Please sign in to comment.