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 pixel
  • dc.drawLine(x1, y1, x2, y2, color) - Draw a line
  • dc.drawRect(x, y, width, height, color) - Draw a rectangle
  • dc.drawText(x, y, text, color) - Draw text
  • dc.clear(color) - Clear the DC

Compositing

DCs are composited by the Compositor onto the framebuffer, enabling window transparency, layering, and effects.