-
Notifications
You must be signed in to change notification settings - Fork 57
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
Set a single pixel #125
Comments
There isn't anything built in to this library that is specifically for drawing individual pixels, but you can add a Bitmap to the This is one of the existing examples modified to add a Bitmap and set some pixels inside of it: import board
from adafruit_pyportal.graphics import Graphics
import displayio
# Set display to show
display = board.DISPLAY
# Background Information
base = Graphics(default_bg=0x990099, debug=True)
# WebPage to show in the QR
webpage = "http://www.adafruit.com"
# QR size Information
qr_size = 9 # Pixels
scale = 3
# Create a barcode
base.qrcode(
webpage,
qr_size=scale,
x=display.width // 2 - qr_size * scale,
y=display.height // 2 - qr_size * scale,
)
# Create a bitmap with two colors
bitmap = displayio.Bitmap(display.width, display.height, 2)
# Create a two color palette
palette = displayio.Palette(2)
palette[0] = 0x000000
palette[1] = 0x00ff00
palette.make_transparent(0)
# Create a TileGrid using the Bitmap and Palette
tile_grid = displayio.TileGrid(bitmap, pixel_shader=palette)
# Draw a pixel
bitmap[20, 20] = 1
# Draw even more pixels
for x in range(50, 70):
for y in range(10, 20):
bitmap[x, y] = 1
base.splash.append(tile_grid)
while True:
pass @harwalan also note that the new Bitmap will get put in front of the other things drawn. Unless you're intending to cover everything up, you'll probably want to set one or more of the colors in the palette to be transparent. Index 0 is set to transparent in this example, then pixels are drawn with index 1. |
I'd love way to set a single pixel. Is there an existing way to do this?
The text was updated successfully, but these errors were encountered: