Skip to content

Instantly share code, notes, and snippets.

@anecdata
Last active July 18, 2020 19:42
Show Gist options
  • Save anecdata/767d29f287110828dbd33707ee85bb59 to your computer and use it in GitHub Desktop.
Save anecdata/767d29f287110828dbd33707ee85bb59 to your computer and use it in GitHub Desktop.
CircuitPython vectorio circles
import board
import displayio
from vectorio import Rectangle, Circle, Polygon, VectorShape
import time
import random
import gc
# Make the display context
SPLASHMAX = 2000
splash = displayio.Group(max_size=SPLASHMAX)
board.DISPLAY.show(splash)
color_palette = []
vector_shape = []
for _ in range(0, SPLASHMAX-1):
try:
circ = Circle(random.randint(1,30))
sx = random.randint(0, 332)
sy = random.randint(0, 240)
color_palette.append(displayio.Palette(2))
color_palette[_].make_transparent(0)
color_palette[_][1] = random.randint(0, 16777216)
vector_shape.append(VectorShape(shape=circ, x=sx, y=sy, pixel_shader=color_palette[_]))
splash.append(vector_shape[_])
# gc.collect()
except MemoryError as e:
print(_, gc.mem_free(), e)
break
while True:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment