Device Context (DC)
Overview
The Device Context (DC) provides an off-screen rendering surface for Node.js applications. It allows applications to draw graphics without directly accessing the framebuffer, enabling windowed applications and compositing.
Architecture
Device Contexts are managed by the Compositor and provide:
- Off-screen bitmap buffers
- Drawing primitives (pixels, lines, rectangles, text)
- Clipping regions
- Alpha blending support
API
Creating a DC
const dc = createDC(width, height);
Drawing Operations
dc.drawPixel(x, y, color)- Draw a pixeldc.drawLine(x1, y1, x2, y2, color)- Draw a linedc.drawRect(x, y, width, height, color)- Draw a rectangledc.drawText(x, y, text, color)- Draw textdc.clear(color)- Clear the DC
Compositing
DCs are composited by the Compositor onto the framebuffer, enabling window transparency, layering, and effects.