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 extend option to add_text #36

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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: 9 additions & 1 deletion pydecorate/decorator_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,15 @@ def _add_text(self, txt, **kwargs):
# draw base
px = self.style["propagation"][0] + self.style["newline_propagation"][0]
py = self.style["propagation"][1] + self.style["newline_propagation"][1]
x1 = x + px * (tw + 2 * mx)
if self.style["extend"]:
if self.style["propagation"][0] == 1:
x1 = x + px * (x_size - x)
elif self.style["propagation"][0] == -1:
x1 = x + px * x
else:
x1 = x + px * (tw + 2 * mx)
else:
x1 = x + px * (tw + 2 * mx)
Comment on lines +281 to +289
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we put this in another helper function or method? And how similar is this code to the scale/colorbar code? Could it be reused?

What do you think about a test that just makes sure that the result is different based on extend False and extend True? It doesn't have to check actual pixel-by-pixel comparison.

y1 = y + py * self.style["height"]
self._draw_rectangle(draw, [x, y, x1, y1], **self.style)

Expand Down