Skip to content

Tilepalettemapper api update #3034

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

Merged
merged 4 commits into from
May 20, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
5 changes: 4 additions & 1 deletion Metro/Metro_RP2350_CircuitPython_Matrix/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@
import supervisor
from displayio import Group, TileGrid
from tilepalettemapper import TilePaletteMapper
from adafruit_fruitjam.peripherals import request_display_config
import adafruit_imageload


# use the built-in HSTX display
request_display_config(320,240)
display = supervisor.runtime.display

# screen size in tiles, tiles are 16x16
Expand Down Expand Up @@ -64,7 +67,7 @@
shader_palette[i + 1] = COLORS[i]

# mapper to change colors of tiles within the grid
grid_color_shader = TilePaletteMapper(shader_palette, 2, SCREEN_WIDTH, SCREEN_HEIGHT)
grid_color_shader = TilePaletteMapper(shader_palette, 2)

# load the spritesheet
katakana_bmp, katakana_pixelshader = adafruit_imageload.load("matrix_characters.bmp")
Expand Down
7 changes: 4 additions & 3 deletions Metro/Metro_RP2350_Match3/match3_game/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,7 @@

# create tile palette mappers
for i in range(2):
palette_mapper = TilePaletteMapper(remap_palette, 3, 1, 1)
# remap index 2 to each of the colors in mouse colors list
palette_mapper[0] = [0, 1, i + 3]
palette_mapper = TilePaletteMapper(remap_palette, 3)
palette_mappers.append(palette_mapper)

# create tilegrid for each mouse
Expand All @@ -228,6 +226,9 @@
mouse_tg.y = display.height // scale_factor // 2
mouse_tgs.append(mouse_tg)

# remap index 2 to each of the colors in mouse colors list
palette_mapper[0] = [0, 1, i + 3]

# USB info lists
mouse_interface_indexes = []
mouse_endpoint_addresses = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class Match3Card(Group):

def __init__(self, card_tuple, **kwargs):
# tile palette mapper to color the card
self._mapper = TilePaletteMapper(kwargs["pixel_shader"], 5, 1, 1)
self._mapper = TilePaletteMapper(kwargs["pixel_shader"], 5)
kwargs["pixel_shader"] = self._mapper
# tile grid to for the visible sprite
self._tilegrid = TileGrid(**kwargs)
Expand Down
2 changes: 0 additions & 2 deletions Metro/Metro_RP2350_Match3/tilepalettemapper_demo/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
tile_palette_mapper = TilePaletteMapper(
spritesheet_bmp.pixel_shader, # input pixel_shader
5, # input color count
3, # grid width
1 # grid height
)

# create a TileGrid to show some cards
Expand Down