Skip to content

pygraphics

๐Ÿ–Œ๏ธ pygraphics

Cross-platform 2D drawing and graphics engine for the PyDevices stack โ€” Area dirty bounding boxes, framebuf-compatible FrameBuffer, embedded romfonts, shapes, and image loaders.

๐Ÿ“ฆ MIP: pygraphics ๐Ÿ PyPI: pydevices-pygraphics โšก Native C & Pure-Python Parity ๐ŸŒ MicroPython ยท CircuitPython ยท CPython ยท Direct WebAssembly ยท Pyodide

๐Ÿ“ Area Bounding Boxes

Every shape and text primitive returns an Area(x, y, w, h) bounding box for partial screen refresh and dirty-rect updates.

๐Ÿ”ค Embedded Romfonts

Zero-dependency built-in 8x8, 8x14, and 8x16 romfonts with arbitrary scaling, transparency, and external .bin file support.

๐Ÿ–ผ๏ธ Streaming BMP565

Stream and slice massive 16-bit RGB565 bitmaps without loading full images into microcontroller RAM.

โšก Hardware Blit Fast-Paths

Direct SPI/SDL bulk blit dispatch with clipping context managers (with draw.clip(...)).


๐Ÿ’ป Live Interactive 2D Drawing Demo

Try editing the drawing primitives below and click โ–ถ Run to execute them with direct MicroPython WebAssembly:

Initializing Pythonโ€ฆ

  

๐Ÿš€ Quick Install

Distribution Channel Role
pydevices-pygraphics TestPyPI Native C-extension wheel for desktop, Android, and CPython (native_cmod)
pygraphics MIP Pure-Python package for microcontrollers and builds without a C compiler (pygraphics_python)
# CPython / Desktop
pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ pydevices-pygraphics
# MicroPython
import mip
mip.install("pygraphics", index="https://PyDevices.github.io/mip")

Explore complete applications and arcade games built with pygraphics:

๐Ÿ”ด Bouncing Balls

High-framerate physics simulation with vector circles and bounding-box collision detection.

โ–ถ Launch Live Demo

๐Ÿ‘พ Alien Arcade

Retro Space Invaders-style sprite engine with transparency and animated framebuffers.

โ–ถ Launch Live Demo

๐Ÿฆ– Dino Runner

Classic obstacle jumping arcade running with dirty scanline refresh and physics.

โ–ถ Launch Live Demo

๐Ÿ•น๏ธ Testris Arcade

Full-featured falling-blocks game with matrix rotation, score tracking, and ghost pieces.

โ–ถ Launch Live Demo


๐Ÿ“š Documentation Map

  • ๐Ÿš€ Getting started โ€” Core drawing workflows, dirty rectangles, and canvases.
  • ๐Ÿ“ฆ Installation โ€” MIP, TestPyPI, wheel building, and platform matrix.
  • ๐ŸŽจ Graphics guide โ€” FrameBuffer vs Draw, clipping stacks, fonts, and blit fast-paths.
  • ๐Ÿ–ผ๏ธ Graphics files โ€” BMP565, PBM, PGM image loaders and streaming.
  • โšก Benchmarks โ€” Native C extension vs Pure-Python performance metrics.
  • ๐Ÿ“š API Reference โ€” Full autogenerated API documentation.