Skip to content

Instantly share code, notes, and snippets.

@anecdata
Last active November 26, 2024 06:23
Show Gist options
  • Save anecdata/e30c763142d7e5775bd7706f6307a8ad to your computer and use it in GitHub Desktop.
Save anecdata/e30c763142d7e5775bd7706f6307a8ad to your computer and use it in GitHub Desktop.
bitmaptools.rotozoom-ed bitmap_label
import board
import terminalio
import displayio
import bitmaptools
import math
from adafruit_display_text import bitmap_label
text_area = bitmap_label.Label(terminalio.FONT, x=25, y=25, text="Hello world")
roto_text_area = displayio.Bitmap(100, 100, 2)
bitmaptools.rotozoom(roto_text_area, text_area.bitmap, angle=math.pi/4)
palette = displayio.Palette(2)
palette[1] = 0xFF00FF
tile_grid = displayio.TileGrid(roto_text_area, pixel_shader=palette)
splash = displayio.Group()
splash.append(tile_grid)
board.DISPLAY.root_group = splash
while True:
pass
@anecdata
Copy link
Author

anecdata commented Nov 26, 2024

Compare to adafruit_display_text .label_direction (90° rotations only):
l_d

import board
import terminalio
import displayio
from adafruit_display_text import label

display = board.DISPLAY
font = terminalio.FONT
color = 0xFFFFFF
t1 = label.Label(font, x=0, y=10, text="LTR", color=color, label_direction="LTR")
t2 = label.Label(font, x=100, y=10, text="RTL", color=color, label_direction="RTL")
t3 = label.Label(font, x=50, y=50, text="TTB", color=color, label_direction="TTB")
t4 = label.Label(font, x=75, y=75, text="UPR", color=color, label_direction="UPR")
t5 = label.Label(font, x=25, y=25, text="DWR", color=color, label_direction="DWR")

splash = displayio.Group()
splash.append(t1)
splash.append(t2)
splash.append(t3)
splash.append(t4)
splash.append(t5)
display.root_group = splash

while True:
    pass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment