Cross-platform drawing primitives used by the GUI facade: text, lines, rectangles and simple pen/brush helpers.
Key exports
drawText(window, x, y, text, color?)textWidth(window, text)— returns pixel width of text using window's current font (Windows: GDI measurement, other backends: estimation)fillRect(window, x, y, width, height, color?, defaultColor?, borderColor?)— whenborderColoris provided, draws an outline around the filled rectangledrawLine(window, x1, y1, x2, y2, color?)releaseResources(window)
Behavior
- On native backends these map to platform drawing APIs (GDI/X11).
- On web backends they record logical draw ops into
window.messagesfor host-side rendering. drawText(...)useswindow.textFontwhen set by the GUI facade (setFont).- Windows GDI paths now restore previously selected pen/brush objects after each draw call to reduce DC state leakage when mixing custom GDI operations.
Example
gd := import('gui-draw')
gd.fillRect(window, 10, 10, 200, 120, gui.rgb(200,80,40))
gd.drawText(window, 16, 28, 'Sample', gui.rgb(248, 232, 242))