Skip to content

Latest commit

 

History

History
26 lines (19 loc) · 1.1 KB

File metadata and controls

26 lines (19 loc) · 1.1 KB

gui-draw

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?) — when borderColor is provided, draws an outline around the filled rectangle
  • drawLine(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.messages for host-side rendering.
  • drawText(...) uses window.textFont when 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))