forth/bgi/demo_bgi.fth · 1366 字节 · 下载原文
\ demo_bgi.fth —— 第 3 层:传统图形接口(BGI / `initgraph` 那一套)
\ demo_bgi.fth — Layer 3: the classic graphics interface (BGI)
\
\ 固定 640×480 + 16 色索引色:`SetColor(4)` 是"4 号色"而不是 RGB。
\ Fixed 640x480 + 16 indexed colours: `SetColor(4)` is palette index 4, not RGB.
\
\ 跑法 / How to run:
\ 手机 vml run examples/forth/bgi/demo_bgi.fth
\ 桌面 vmlcli Examples/forth/bgi/demo_bgi.fth --frames /tmp/bgi
\
\ ⚠ `InitGraph(gd, gm, path)` 的前两个实参是 C 的 `int*`。本前端没有 `vml_alloc`,
\ 但 `VARIABLE` 压出的就是那一格的地址:`GD` / `GM` 各自够用。
\ ⚠ The first two arguments are C `int*`. This front end has no `vml_alloc`, but a
\ `VARIABLE` pushes the address of its cell — `GD` / `GM` are enough.
\
\ 声明来自 `Lib/forth/bgi.fth`(GenLib 生成);画完先交帧再关窗,否则 `--frames` 导出 0 帧。
\ Declarations come from `Lib/forth/bgi.fth` (GenLib). Present before closing, or
\ `--frames` exports nothing.
#param lib("bgi.vml")
#param lib("vmlui.vml")
#include <bgi.fth>
#include <vml_ui.fth>
VARIABLE GD
VARIABLE GM
S" " DROP GM GD InitGraph
0 SetBkColor
ClearDevice
4 SetColor
20 20 300 200 Line
14 SetColor
320 240 60 Circle
10 SetColor
40 40 220 160 Rectangle
S" demo_bgi.fth" DROP 30 30 OutTextXY
ui_2d_present
CloseGraph