Last active
April 9, 2024 12:03
-
-
Save todbot/5b649b0ff314f2e723b6dd68d36c05b5 to your computer and use it in GitHub Desktop.
starting to play with bitmapfilter in CircuitPython for Processing- / p5js-like effects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# starting to play with bitmapfilter | |
# 31 Mar 2024 - @todbot / Tod Kurt | |
import time, math, random | |
import board | |
import vectorio | |
import displayio | |
import bitmaptools | |
import bitmapfilter | |
display = board.DISPLAY | |
display.auto_refresh = False | |
dw,dh = display.width, display.height | |
maingroup = displayio.Group() | |
display.root_group = maingroup | |
bitmap = displayio.Bitmap(dw, dh, 65535) | |
pixel_shader = displayio.ColorConverter(input_colorspace=displayio.Colorspace.RGB565_SWAPPED) | |
tile_grid = displayio.TileGrid(bitmap, pixel_shader=pixel_shader) | |
maingroup.append(tile_grid) | |
x,y = 0,0 | |
last_time = 0 | |
while True: | |
for i in range(2): | |
x = random.randint(0,dw-1) | |
y = random.randint(0,dh-1) | |
c = random.randint(0,65535) | |
bitmaptools.draw_circle(bitmap, x, y, 7, c) | |
bitmaptools.draw_circle(bitmap, x, y, 6, c) | |
if time.monotonic() - last_time > 0.2: | |
last_time = time.monotonic() | |
bitmapfilter.morph(bitmap, (1, 2, 1, 2, 4, 2, 1, 2, 1) ) # 3x3 gaussian blur | |
display.refresh() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Video demo: https://mastodon.social/@todbot/112197138537048342