Graphics Engine Capabilities
Key features distinguishing pygraphics from standard framebuf.Dirty Bounding Area Tracking
Every drawing method (fill_rect, circle, line, text) returns an Area(x, y, w, h) bounding box for partial screen updates.
Exposed Read-Only Attributes
Direct access to fb.buffer, fb.width, fb.height, fb.format, and fb.color_depth for zero-copy driver flushing (stride is an internal implementation detail, not a public attribute).
24-bit True Color (RGB888)
Native 24-bit pixel support ideal for high-res display panels as well as NeoPixel (WS2812B) and DotStar (APA102) LED matrix arrays.
Multi-Font Bitmap Engine
Includes built-in text8 (8x8), text14 (8x14), text16 (8x16) fonts, plus custom font object rendering.
Transparent Colorkey Blitting
blit_transparent() enables sprite rendering and icon compositing with custom transparent colorkey masks.
Dual-Mode Invocation
Invoke via OOP methods (fb.circle(...)), standalone functions (pygraphics.circle(fb, ...)), or the Draw styling context.
API Code Example
Dirty Area tracking and FrameBuffer creation.from pygraphics import Area, FrameBuffer, RGB565, framebuf_backend
# Verify active backend (native C usermod or pure-Python fallback)
print("Active backend:", framebuf_backend())
# Allocate 16-bit RGB565 buffer
buf = bytearray(128 * 128 * 2)
fb = FrameBuffer(buf, 128, 128, RGB565)
fb.fill(0)
# Draw circle — returns modified dirty Area bounding box
dirty_area = fb.circle(64, 64, 30, 0xF800, f=True)
print("Dirty Area:", dirty_area) # Area(34, 34, 60, 60)