Skip to content

Instantly share code, notes, and snippets.

@todbot
Last active April 9, 2024 12:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save todbot/5b649b0ff314f2e723b6dd68d36c05b5 to your computer and use it in GitHub Desktop.
Save todbot/5b649b0ff314f2e723b6dd68d36c05b5 to your computer and use it in GitHub Desktop.
starting to play with bitmapfilter in CircuitPython for Processing- / p5js-like effects
# 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()
@todbot
Copy link
Author

todbot commented Apr 1, 2024

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