Node.js Integration
Overview
The Node.js Integration component provides the interface between Node.js applications and the native rendering engine. It enables Node.js applications to render graphics, handle input, and interact with the FreeWorld OS windowing system.
Architecture
The Node.js integration follows a hybrid architecture:
- Node.js Layer: High-level application logic and UI framework
- Graphics Bridge: Interface between Node.js and kernel graphics
- Kernel Graphics: Native assembly rendering primitives
Components
1. Graphics Bridge
Location: system/graphics-bridge.js
Provides access to kernel VESA framebuffer:
- Framebuffer initialization
- Pixel-level drawing operations
- Window buffer blitting
- Screen clearing
2. Device Context (DC)
Location: system/dc.js
Off-screen rendering surfaces for Node.js applications:
- RGBA bitmap buffers
- Drawing primitives
- Clipping regions
3. Compositor
Location: system/compositor.js
Merges window buffers before sending to screen:
- Z-order management
- Alpha blending
- Shadow rendering
Integration Points
- Kernel Graphics: Direct framebuffer access via graphics bridge
- Window System: Window creation and management
- Input System: Mouse and keyboard input handling
- Event System: Event bus for component communication
Usage
// Node.js application using FreeWorld OS graphics
const { createDC } = require('./system/dc');
const Compositor = require('./system/compositor');
// Create a device context for rendering
const dc = createDC(800, 600);
// Draw to the DC
dc.drawRect(0, 0, 800, 600, 0xFF0000FF); // Blue background
dc.drawText(100, 100, 'Hello, FreeWorld OS!', 0xFFFFFFFF);
// Composite to screen
const compositor = new Compositor(1920, 1080);
compositor.registerWindow(hwnd, dc);
compositor.render();
Related Documentation
- Rendering System - Native rendering engine
- Device Context - Off-screen rendering
- Compositor - Window compositing
- Graphics System - Kernel graphics