Closed
Description
When using DWR or UPR label_direction, the label's background is displayed incorrectly.
I don't know what the intention is, if the padding should follow the rotation (top becoming right), or not, but that's not what is going on here anyway. It seems that only the background box position is wrong, not the label's position.
In this example each label.Label is in color, uses the "DWR" direction, with a single padding value not set to 0 as indicated by the text of the label. The appearance I would expect (if the padding matches the rotation) is shown behind it in gray, generated with a fixed bitmap_label.Label using the same parameters.
# setup the display (this was tested on a CPB with TFT gizmo)
# display = ...
from adafruit_display_text import label, bitmap_label
import time
import displayio
import terminalio
import vectorio
# Make the display context
splash = displayio.Group(x=1, y=1, scale=3)
display.show(splash)
display.auto_refresh = False
color_palette = displayio.Palette(3)
color_palette[0] = 0x008000 # Bright Green
color_palette[1] = 0x808080 # 0xAA0088
color_palette[2] = 0x000022
lines = displayio.Group()
for num in range(21):
y = 10 * num
if num % 5 == 0:
COLOR = 0
else:
COLOR = 1
lines.append(vectorio.Rectangle(pixel_shader=color_palette,
width=display.width, height=1, x=0, y=y, color_index=COLOR,
))
lines.append(vectorio.Rectangle(pixel_shader=color_palette,
width=1, height=display.height, x=y, y=0, color_index=COLOR,
))
TEXT = "AB"
DIRECTION = "LTR" # LTR / RTL / UPR / DWR
RED = 0xFF0000
text_group = displayio.Group(scale=1, x=0, y=0)
def add_text(border=0, x=0, y=0, anchor=(0,0), scale=1,
direction="LTR", color=RED, text=TEXT,
):
position = (x, y)
if isinstance(border, int):
border = (border, border, border, border)
text_area1 = bitmap_label.Label(
terminalio.FONT, text=text, color=0xFFFFFF,
anchor_point=anchor,
anchored_position=position,
padding_top = border[0],
padding_bottom = border[1],
padding_left = border[2],
padding_right = border[3],
background_color = 0x606060,
scale = scale,
label_direction=direction,
)
text_area2 = label.Label(
terminalio.FONT, text=text, color=0xFFFFFF,
anchor_point=anchor,
anchored_position=position,
padding_top = border[0],
padding_bottom = border[1],
padding_left = border[2],
padding_right = border[3],
background_color = color, # 0x606060,
scale = scale,
label_direction=direction,
)
text_group.append(text_area1)
text_group.append(text_area2)
add_text(border=(5,0,0,0), x=10, y=10, direction="DWR", text="TOP")
add_text(border=(0,5,0,0), x=10, y=50, direction="DWR", text="BTM", color=0x0000FF)
add_text(border=(0,0,5,0), x=50, y=10, direction="DWR", text="LFT", color=0x008000)
add_text(border=(0,0,0,5), x=50, y=50, direction="DWR", text="RGT", color=0xA08000)
splash.append(text_group)
splash.append(lines)
display.refresh()
while True:
pass
Metadata
Metadata
Assignees
Labels
No labels