Ling — The Omniglot Systems Language
Ling is a polyglot scripting language whose keywords and builtins are available in 16+ human languages simultaneously — Chinese, Thai, Korean, Japanese, English, Arabic, Hebrew, Russian, and more — in the same source file.
# All four in one file:
令 启 = 执 { 印("你好") } # Chinese
令 เริ่ม = ดำเนินการ { พิมพ์("สวัสดี") } # Thai
bind start = do { print("Hello") } # English
바인드 시작 = 수행 { 인쇄("안녕") } # Korean
Core features
- Polyglot keywords — write loops in Chinese, functions in Thai, variables in English
- 3D software renderer — vector geometry (
vtex_*) and pixel textures (tex_*) - 4D spatial audio — pentatonic synthesis with positional mixing
- FFT analysis — frequency bands from any audio source
- Cross-platform — native Windows/macOS/Linux and WebGL2 WASM
Crates
| Crate | Version | Purpose |
|---|---|---|
ling-lang | 2030.1.3 | Main interpreter binary |
ling-core | 2030.0.0 | Core types |
ling-audio | 2030.0.0 | 4D audio + FFT |
ling-game | 2030.0.0 | ECS, mesh, physics |
ling-graphics | 2030.0.0 | 3D/4D rendering |
ling-crypto | 2030.0.0 | Cryptography |
ling-net | 2030.0.0 | Async networking |
ling-ai | 2030.0.0 | LLM / neural nets |
Quick navigation
Ling — Showcase
Ling is the omniglot creative-systems language: you write the same program in English, 中文, 日本語, 한국어, or ไทย — keywords, builtins, even file names — and it runs identically. One small native binary gives you a 3D/4D holographic renderer, vector fonts, a UI toolkit, a music studio (decode · BPM/key · GM synth · MIDI · karaoke), spatial audio, post-quantum crypto, and a physics lab — no engine install, no package soup.
# the same program, four ways — all run:
bind start = do { open_window(800, 600) draw_disc(400.0, 300.0, 120.0) present() }
绑定 开始 = 做 { 开窗(800.0, 600.0) 画实心圆(400.0, 300.0, 120.0) 显() }
バインド 開始 = 実行 { ウィンドウ開く(800,600) 塗りつぶし円(400,300,120) 表示() }
ผูก เริ่ม = ทำ { เปิดหน้าต่าง(800,600) วาดวงกลมทึบ(400,300,120) แสดงผล() }
lingfu normalize <lang> rewrites any Ling project into a single language — so a team can
each read the code in their own tongue and commit a normalized form.
What makes Ling unique
- Polyglot by design — five human languages are first-class, not comments or i18n strings. Every keyword and ~hundreds of builtins have native aliases; the lexer/parser accept any mix.
- Batteries welded in — graphics, vector fonts, UI, music, MIDI, spatial audio, crypto, physics and AI tensors ship in the one toolchain. First pixel in ~5 lines.
- 3D and 4D / holographic — a depth-sorted software renderer with a cel/holographic shader,
4D camera projection, and vector-texture primitives (
vtex_*). - Resolution-independent vector fonts — TrueType outlines cached as
.lingglyph files and rendered (stroke or fill) crisp in 2D/3D/4D, in every script (灵 · ABC · あ · 가 · ก). - A real music layer — load WAV/FLAC/OGG/MP3, extract BPM & musical key, synthesize any
GM-style instrument from a
.lingpatch, read MIDI, build rhythm games & karaoke. - Post-quantum crypto built in — hashes, AEAD, signatures, ML-KEM/X25519 hybrids, Shamir, Schnorr/VRF — usable from a script in one call.
- Physics from a script — rigid + angular dynamics, deformable soft-body meshes, and a fast immiscible water/oil liquid sim that maps onto plane/sphere/cylinder/cone/dome.
- Tiny & native — one binary, software-rendered (no GPU driver required), runs headless for CI frame-capture; also targets WASM.
How Ling compares
Legend: ● built-in · ◐ partial / via add-on · ○ not a goal.
| Capability | Ling | Unity | Godot | Bevy (Rust) | Pygame | p5.js | LÖVE |
|---|---|---|---|---|---|---|---|
| Source in 5 human languages | ● | ○ | ○ | ○ | ○ | ○ | ○ |
| Single self-contained binary | ● | ○ | ◐ | ● | ◐ | ○ | ◐ |
| No GPU/driver required (software) | ● | ○ | ○ | ○ | ● | ◐ | ○ |
| 3D rendering | ● | ● | ● | ● | ○ | ◐ | ○ |
| 4D / hyperbolic / holographic | ● | ○ | ○ | ○ | ○ | ○ | ○ |
| Vector fonts (2D/3D/4D) | ● | ◐ | ◐ | ◐ | ◐ | ◐ | ◐ |
| Immediate-mode UI toolkit | ● | ◐ | ● | ◐ | ○ | ○ | ◐ |
| Audio playback | ● | ● | ● | ● | ● | ● | ● |
| Spatial (3D/4D) audio + FX | ● | ● | ● | ◐ | ○ | ◐ | ◐ |
| BPM / musical-key analysis | ● | ○ | ○ | ○ | ○ | ◐ | ○ |
| GM-style synth from a patch file | ● | ◐ | ◐ | ○ | ○ | ◐ | ○ |
| MIDI load + rhythm/karaoke kit | ● | ◐ | ◐ | ○ | ◐ | ◐ | ○ |
| Rigid + angular physics | ● | ● | ● | ◐ | ○ | ○ | ◐ |
| Soft-body / deformable mesh | ● | ◐ | ◐ | ◐ | ○ | ○ | ○ |
| Fast immiscible liquid sim | ● | ◐ | ◐ | ○ | ○ | ○ | ○ |
| Post-quantum crypto built in | ● | ○ | ○ | ○ | ○ | ○ | ○ |
| Headless CI frame capture | ● | ◐ | ◐ | ◐ | ◐ | ○ | ◐ |
| Lines to first pixel | ~5 | many | ~15 | ~40 | ~10 | ~5 | ~8 |
Comparisons are about what ships in the box. Mature engines like Unity/Godot/Bevy have far deeper 3D pipelines, tooling and ecosystems — Ling’s angle is breadth-in-one-binary plus the things no one else has: truly multilingual source, 4D/holographic vector rendering, built-in music analysis + GM synth, and post-quantum crypto.
See it run
| Demo | What it shows |
|---|---|
examples/music/hallway_runner.ling | Auto-playing FFT-reactive infinite runner; MIDI-driven coins ring the melody as spatial SFX |
examples/music/karaoke_hero.ling | Karaoke-Hero pitch bars from a vocal MIDI + live mic tuner |
examples/music/synth_jam.ling | GM instruments synthesized from .ling patches |
examples/physics/bouncy_ball.ling | Spring-mass soft body squashing as it bounces |
examples/physics/tumbling.ling | Rigid bodies tumbling & rolling (angular dynamics) |
examples/physics/liquid_marble.ling | Water+oil sim mapped onto a spinning sphere/cone/dome |
examples/ui/hud_showcase.ling | The full vector UI toolkit (HUD, meters, controls, game UI) |
examples/crypto/crypto_donut_physics.ling | A SHA3 hash → a bouncing knot-torus with reactive audio |
cargo run --bin ling -- examples/physics/liquid_marble.ling
See the full reference (in 5 languages) at https://docs.ling-lang.org.
Installation
From crates.io
cargo install ling-lang
From source
git clone https://github.com/taellinglin/ling
cd ling
cargo build --release
# binary at target/release/ling
Requirements
- Rust 1.75+
- On Linux:
libasound2-dev(for audio) - On macOS/Windows: no extra dependencies
Run a script
ling examples/basics/thai_hello_world.ling
Hello World
Ling supports any Unicode identifier. All built-in keywords work in every supported language simultaneously in the same source file.
English
bind start = do {
print("Hello, World!")
}
Chinese 中文
令 启 = 执 {
印("你好,世界!")
}
Thai ภาษาไทย
ผูก เริ่ม = ทำ {
พิมพ์("สวัสดีชาวโลก")
}
Korean 한국어
바인드 시작 = 실행 {
print("안녕하세요, 세계!")
}
Mixed (all valid simultaneously)
令 启 = 执 {
若 true {
印("Hello from 中文!")
}
bind x = 42
println(x)
}
Your First 3D Room
A minimal windowed scene with a floor grid and a spinning chakra mandala.
令 PI = 3.14159265
令 启 = 执 {
open_fullscreen("My First Room")
set_ambient(0.15)
令 帧 = 0
循 window_is_open() {
fill(0, 0, 8) # deep-blue background
令 ry = 帧 * 0.0006
set_camera(cos(ry), sin(ry), 1.0, 0.0)
set_camera_pos(sin(ry) * 6.0, 1.0, cos(ry) * 6.0)
set_zdist(2.0)
# Floor grid
vtex_grid(0, -3, 0, 1,0,0, 0,0,1, 8, 8, 1.0, 1.0, 帧*0.0001, 1.57)
# Spinning mandala
vtex_chakra(0, 0, 0, 1,0,0, 0,1,0, 2.5, 8, 帧*0.0005, 3.50)
vtex_lotus( 0, 0, 0, 1,0,0, 0,1,0, 0.6, 2.2, 8, 帧*0.0004, 2.10)
display()
令 帧 = 帧 + 1
}
}
Save as room.ling and run:
ling room.ling
Press Escape or close the window to exit.
Syntax Reference
Ling is an expression-oriented language with a clean, minimal syntax. Every keyword below has equivalents in all supported lexicons — see Keyword Aliases for the full table.
Binding (variable declaration)
令 x = 42
令 name = "Ling"
令 flag = true
Re-binding shadows the previous binding in the same scope:
令 i = 0
令 i = i + 1 # i is now 1
Functions
函 add(a, b) {
返 a + b
}
Functions are values and can be stored in bindings:
令 square = 函 (n) { 返 n * n }
令 result = square(7) # 49
Do blocks (执)
A 执 block evaluates all statements and returns the value of the last one.
The entry point of every Ling program is 令 启 = 执 { ... }.
令 启 = 执 {
令 x = 10
令 y = 20
印(x + y)
}
Conditionals
若 x > 0 {
印("positive")
}
若 x > 0 {
印("positive")
} 否则 {
印("non-positive")
}
While loops
令 i = 0
循 i < 10 {
印(i)
令 i = i + 1
}
Note: Ling has no unary minus operator. Write
0 - xinstead of-x.
Lists
令 lst = list_new()
令 lst = list_push(lst, 42)
令 lst = list_push(lst, "hello")
令 n = list_len(lst) # 2
令 v = list_get(lst, 0) # 42
Comments
# This is a comment
令 x = 1 # inline comment
Arithmetic and comparison
令 sum = a + b
令 diff = a - b
令 prod = a * b
令 quot = a / b
令 rem = a % b
令 eq = a == b
令 neq = a != b
令 lt = a < b
令 lte = a <= b
令 gt = a > b
令 gte = a >= b
Built-in math functions
sin(x) cos(x) tan(x)
asin(x) acos(x) atan2(y, x)
sqrt(x) abs(x) floor(x) ceil(x)
log(x) exp(x) pow(x, y)
Core Builtins Reference
All builtins support multilingual names — see Builtin Aliases for the full international lookup table.
Every alias listed in the 5-language tables below is accepted by the
interpreter, the lexer/parser, and the lingfu normalize command, so an
English program normalized to any of these languages runs unchanged. The
interpreter accepts the union of every alias, so you can mix languages in one
file.
Output · Core
| EN | 🇨🇳 ZH | 🇯🇵 JA | 🇰🇷 KO | 🇹🇭 TH | Description |
|---|---|---|---|---|---|
print / println | 印 / 打印 | 印刷 | 출력 | พิมพ์ | Print value(s) to stdout |
format | 格式 | フォーマット | 서식 | รูปแบบ | Format string with args |
ok | 好 | 良し | 좋아 | โอเค | Wrap value as Ok |
bad / err | 坏 | 悪い | 나쁨 | ผิด | Wrap value as Err |
sleep | 睡眠 | 眠る / スリープ | 잠자기 / 잠 | หยุด / นอน | Sleep for N ms |
Math
All math args and results are f64. Angles are in radians.
| EN | 🇨🇳 ZH | 🇯🇵 JA | 🇰🇷 KO | 🇹🇭 TH | Description |
|---|---|---|---|---|---|
sin | 正弦 | サイン | 사인 | ไซน์ | Sine |
cos | 余弦 | コサイン | 코사인 | โคไซน์ | Cosine |
tan | 正切 | タンジェント | 탄젠트 | แทนเจนต์ | Tangent |
asin | 反正弦 | アークサイン | 아크사인 | อาร์กไซน์ | Arcsine |
acos | 反余弦 | アークコサイン | 아크코사인 | อาร์กโคไซน์ | Arccosine |
atan | 反正切 | アークタンジェント | 아크탄젠트 | อาร์กแทนเจนต์ | Arctangent |
atan2 | 反正切2 | アークタンジェント2 | 아크탄젠트2 | — | Two-arg arctangent |
tanh | 双曲正切 | 双曲線正接 | 쌍곡탄젠트 | — | Hyperbolic tangent |
sqrt | 平方根 / 根 | 平方根 | 제곱근 | รากที่สอง | Square root |
cbrt | 立方根 | 立方根 | 세제곱근 | รากที่สาม | Cube root |
pow | 幂 | べき乗 | 거듭제곱 | ยกกำลัง | x raised to y |
exp | 指数 | 指数関数 | 지수 | — | e^x |
hypot | 斜边 | 斜辺 | 빗변 | — | √(x²+y²) |
ln / log | 对数 | 対数 | 로그 | ลอการิทึม | Natural log |
log2 / log10 | 对数2 / 对数10 | 対数2 / 対数10 | 로그2 / 로그10 | — | Base-2 / base-10 log |
abs | 绝对值 / 绝对 | 絶対値 | 절댓값 / 절대값 | ค่าสัมบูรณ์ | Absolute value |
floor | 向下取整 / 下整 | 床関数 | 내림 | ปัดลง | Round down |
ceil | 向上取整 / 上整 | 天井関数 | 올림 | ปัดขึ้น | Round up |
round | 四舍五入 / 四舍 | 四捨五入 | 반올림 | ปัดเศษ | Round to nearest |
trunc / int | 取整 / 整数 | 整数化 / 切り捨て | 정수화 / 정수 | ตัดทศนิยม | Truncate toward zero |
fract | 小数部分 | 小数部 | 소수부 | — | Fractional part |
min | 最小 | 最小 | 최솟값 | ต่ำสุด | Minimum of two |
max | 最大 | 最大 | 최댓값 | สูงสุด | Maximum of two |
clamp | 截取 | 範囲制限 | 범위제한 | จำกัด | Clamp to [lo, hi] |
pi | 圆周率 | 円周率 | 파이 | พาย | π constant |
tau | 双周率 | タウ | 타우 | ทาว | τ constant (2π) |
Cells marked
—have no native alias in that language yet (English still works everywhere). Filling these is tracked inTODO.md.
Lists
| EN | 🇨🇳 ZH | 🇯🇵 JA | 🇰🇷 KO | 🇹🇭 TH | Description |
|---|---|---|---|---|---|
list_new | 新建列表 | 新規リスト | 새목록 | รายการใหม่ | Create empty list |
list_push | 列表添加 | リスト追加 | 목록추가 | เพิ่มรายการ | Append value, return new list |
list_get | 取元素 | 要素取得 | 요소가져오기 | รับรายการ | Get element at index |
list_join / join | 连接 | 連結 | 연결 | รวมรายการ | Join list into a string |
len / str_len | 长度 | 長さ | 길이 | ความยาว | Length of list or string |
Strings
| Function | Description |
|---|---|
str_len(s) | Length in characters |
str_concat(a, b) | Concatenate strings |
str_slice(s, start, end) | Substring |
str_to_num(s) | Parse as number |
num_to_str(n) | Number to string |
str_contains(s, sub) | Substring test |
Type checks
| Function | Returns |
|---|---|
is_num(v) | true if number |
is_str(v) | true if string |
is_list(v) | true if list |
is_bool(v) | true if boolean |
Window & display
See Window & Camera reference.
Vector geometry
See vtex reference.
Pixel textures
See tex reference.
Audio
See Audio reference.
Cryptography & Physics
ling-crypto (Blake3, SHA-3, AES-GCM-256, XChaCha20, Ed25519, X25519, Shamir,
Schnorr, VRF …) and ling-physics (vectors, rigid bodies, forces, hyperbolic
geometry) are exposed as Rust crate APIs, not yet as .ling builtins — call
them from Rust, or via a host that embeds the interpreter. Coverage is verified
by the crate test suites (crates/ling-crypto/tests, crates/ling-physics/tests).
Wiring them in as multilingual builtins is tracked in
TODO.md.
FFT (native only, no-op on WASM)
| Function | Description |
|---|---|
fft_push(samples) | Feed list of f32 samples to analyzer |
fft_bands(n) | Return n log-spaced magnitude bands (0..1) |
fft_beat() | true if current frame energy exceeds average |
fft_beat_ratio() | energy ratio (1.0 = threshold) |
fft_rms() | RMS level of current window |
fft_dominant_freq() | Peak frequency in Hz |
3-D Primitive Shapes
The shape builtins are Ling’s “Inkscape for 3-D” — a library of parametric solids (boxes, spheres, dice, cogs, gyros…) that render as lit filled triangles, wireframe, or both. Every shape shares one uniform call signature, so once you know one you know them all.
name(cx,cy,cz, sx,sy,sz, rx,ry,rz, mode, e0, e1, e2)
| Group | Params | Meaning |
|---|---|---|
| Centre | cx, cy, cz | world-space position of the shape’s centre |
| Scale | sx, sy, sz | per-axis size (half-extent). Non-uniform values give stretched cubes, ellipsoids, flat discs, … |
| Rotation | rx, ry, rz | Euler rotation in radians, applied X → Y → Z |
| Mode | mode | 0 = filled · 1 = wireframe · 2 = both (wire drawn on top) |
| Extras | e0, e1, e2 | shape-specific (segment counts, sides, ratios). Omit or pass 0 for sensible defaults |
The current pen colour (set_color / สีดินสอ / 设色 …) drives both the
fill lighting (cel-shaded against the active lights) and the wireframe colour.
Shapes are depth-sorted with the rest of the scene and flushed on present().
Camera note: like all 3-D draws, shapes are projected through the camera set with
set_camera(...). Keep the camera at the origin and place shapes in front at positive Z (the same convention the room demos use).
Quick start
bind start = do {
open_fullscreen("shapes")
set_ambient(0.25)
add_light(4, 4, 8, 4.0, 255, 240, 220)
bind FR = 0
while window_is_open() {
fill(4, 5, 12)
set_camera(1, 0, 1, 0)
bind a = FR * 0.02
set_color(230, 120, 90)
cube(-2, 0, 9, 0.8,0.8,0.8, a, a*0.7, 0, 0) # filled cube
set_color(120, 200, 255)
icosahedron(0, 0, 9, 0.9,0.9,0.9, a, a, 0, 2) # d20, fill+wire
set_color(190, 190, 200)
gear(2, 0, 9, 0.8,0.3,0.8, 1.57, a*2, 0, 0, 14, 0.3) # spinning cog
present()
bind FR = FR + 1
}
}
Draw modes
mode | Result |
|---|---|
0 | Filled — cel-lit triangles |
1 | Wireframe — edges only, in the pen colour |
2 | Both — filled, with the wireframe biased slightly nearer so it reads on top |
Rendering & lighting modes (holographic cel)
Shape fills use an anime / holographic cel model by default: surfaces are lit with smooth (averaged) vertex normals, the lit colour is interpolated across each triangle, then posterised per pixel into crisp luminance bands. The result is smooth shading with no faceted triangle edges, but clean toon bands that curve over the surface — plus coloured lights, coloured shadows, and a Fresnel rim glow.
| Builtin | Args | Effect |
|---|---|---|
set_shade_mode(m) | 0 flat · 1 cel · 2 holo (default) | overall style |
set_cel_bands(n) | n ≥ 2 (default 4) | number of posterisation bands — lower = chunkier |
set_shadow_color(r,g,b) | 0–255 | tint of unlit regions (coloured shadows) |
set_rim(strength, r,g,b) | strength + 0–255 | Fresnel edge-glow colour/intensity |
set_shade_mode(2) # holographic cel (default)
set_cel_bands(4) # 4 bands
set_shadow_color(28,36,90) # cool indigo shadows
set_rim(0.7, 120,220,255) # cyan holographic edge
- Mode 0 (flat): legacy per-face cel — every triangle one flat band (faceted).
- Mode 1 (cel): smooth bands, no rim/sheen — clean toon.
- Mode 2 (holo): smooth bands + Fresnel rim + a subtle normal-gradient sheen.
Lighting comes from add_light(x,y,z, intensity, r,g,b) (each light contributes
its own colour) and set_ambient(level). The lighting math lives in the
ling-graphics crate (ling_graphics::shading).
Round & swept solids
cube · box — 立方体 · 方块 · 정육면체 · ลูกบาศก์ (box: 方块/箱/상자/กล่อง)
Axis-aligned box. Non-uniform sx,sy,sz make any rectangular block.
cube(cx,cy,cz, sx,sy,sz, rx,ry,rz, mode)
sphere — 球体 · 球 · 구 · ทรงกลม
UV sphere. Scale axes independently for an ellipsoid.
sphere(cx,cy,cz, sx,sy,sz, rx,ry,rz, mode, segments=16, rings=12)
icosphere — 二十面球 · アイコ球 · 아이코구체 · ทรงกลมเหลี่ยม
Geodesic sphere from a subdivided icosahedron (more even than a UV sphere).
icosphere(cx,cy,cz, sx,sy,sz, rx,ry,rz, mode, subdivisions=1) # 0..4
dome — 穹顶 · ドーム · 돔 · โดม
Hemisphere with a closing base — useful for cupolas and skies.
dome(cx,cy,cz, sx,sy,sz, rx,ry,rz, mode, segments=24, rings=8)
cylinder — 圆柱 · 円柱 · 원기둥 · ทรงกระบอก
Capped tube (height runs along local Y, scaled by sy).
cylinder(cx,cy,cz, sx,sy,sz, rx,ry,rz, mode, segments=24)
cone — 圆锥 · 円錐 · 원뿔 · กรวย
Capped cone, apex at +Y.
cone(cx,cy,cz, sx,sy,sz, rx,ry,rz, mode, segments=24)
capsule — 胶囊 · カプセル · 캡슐 · แคปซูล
Cylinder with hemispherical caps (a “pill”).
capsule(cx,cy,cz, sx,sy,sz, rx,ry,rz, mode, segments=16, rings=6)
torus · ring — 圆环 · トーラス · 토러스 · ทอรัส
Donut. tube is the tube radius as a fraction of the outer radius.
torus(cx,cy,cz, sx,sy,sz, rx,ry,rz, mode, segments=32, sides=12, tube=0.35)
Prisms & pyramids
pyramid — 金字塔 · ピラミッド · 피라미드 · พีระมิด
N-sided pyramid. sides=4 is the classic square pyramid.
pyramid(cx,cy,cz, sx,sy,sz, rx,ry,rz, mode, sides=4)
prism — 棱柱 · 角柱 · 각기둥 · ปริซึม
N-sided prism (extruded polygon). sides=3 → triangular prism, 6 → hex column.
prism(cx,cy,cz, sx,sy,sz, rx,ry,rz, mode, sides=6)
frustum — 棱台 · 錐台 · 원뿔대 · กรวยตัด
Truncated cone/pyramid. top_ratio is the top radius as a fraction of the base
(0 → cone, 1 → cylinder).
frustum(cx,cy,cz, sx,sy,sz, rx,ry,rz, mode, sides=24, top_ratio=0.5)
Dice (Platonic solids)
Perfect for dice, gems, and crystal shapes — all take no extra params.
| Builtin | Die | Aliases |
|---|---|---|
tetrahedron | d4 | d4 · 四面体 · 정사면체 · ทรงสี่หน้า |
cube | d6 | (see above) |
octahedron | d8 | d8 · 八面体 · 정팔면체 · ทรงแปดหน้า |
dodecahedron | d12 | d12 · 十二面体 · 정십이면체 · ทรงสิบสองหน้า |
icosahedron | d20 | d20 · 二十面体 · 정이십면체 · ทรงยี่สิบหน้า |
icosahedron(cx,cy,cz, sx,sy,sz, rx,ry,rz, mode)
d20(cx,cy,cz, sx,sy,sz, rx,ry,rz, mode) # same thing
Mechanical & architectural
gear · cog — 齿轮 · 歯車 · 톱니바퀴 · เฟือง
Extruded spur gear in the XZ plane. teeth count and tooth depth are
configurable; thickness comes from sy.
gear(cx,cy,cz, sx,sy,sz, rx,ry,rz, mode, teeth=12, tooth=0.25)
gyro — 陀螺 · ジャイロ · 자이로 · ไจโร
Nested gimbal: rings concentric tori on alternating axes — a gyroscope / armillary.
gyro(cx,cy,cz, sx,sy,sz, rx,ry,rz, mode, rings=3)
arch — 拱门 · アーチ · 아치 · ซุ้มโค้ง
Semicircular archway (tube swept over 180°).
arch(cx,cy,cz, sx,sy,sz, rx,ry,rz, mode, segments=24, tube=0.18)
stairs — 楼梯 · 階段 · 계단 · บันได
Staircase of steps cuboid steps rising along +Y/+Z.
stairs(cx,cy,cz, sx,sy,sz, rx,ry,rz, mode, steps=5)
Curves & surfaces
helix — 螺旋线 · らせん · 나선 · เกลียว
Tube swept along a helix around Y.
helix(cx,cy,cz, sx,sy,sz, rx,ry,rz, mode, turns=3, tube=0.15, sides=8)
spring — 弹簧 · ばね · 스프링 · สปริง
A tighter, thinner helix (coil). Same params as helix.
spring(cx,cy,cz, sx,sy,sz, rx,ry,rz, mode, turns=6, tube=0.12, sides=8)
star_prism · star — 星柱 · 별기둥 · แท่งดาว
An N-point star cross-section extruded along Y.
star_prism(cx,cy,cz, sx,sy,sz, rx,ry,rz, mode, points=5, inner_ratio=0.5)
capsule_chain · chain — 胶囊链 · カプセル鎖 · 캡슐체인 · โซ่แคปซูล
A row of count capsule beads along X — a chain / caterpillar.
capsule_chain(cx,cy,cz, sx,sy,sz, rx,ry,rz, mode, count=3)
mobius — 莫比乌斯 · メビウス · 뫼비우스 · เมอบีอุส
A half-twisted Möbius band.
mobius(cx,cy,cz, sx,sy,sz, rx,ry,rz, mode, segments=60, width=0.3)
Tips
- Flat disc / plate:
cylinderwith a smallsy(e.g.0.05). - Ellipsoid:
spherewith unequalsx,sy,sz. - Obelisk:
frustumwith a smalltop_ratioand tallsy. - Animate by feeding the frame counter into
rx,ry,rzeach frame. - Outlined solid: use
mode = 2and a bright pen colour for a crisp cel-look with ink edges.
All shape names are available in every Ling language; see Builtin Aliases by Language.
Vector Geometry Builtins (vtex_*)
All vtex_* functions draw line-based 3D geometry onto a plane defined by:
- Centre
(cx, cy, cz)— world-space anchor point - U tangent
(ux, uy, uz)— “right” direction in the plane - V tangent
(vx, vy, vz)— “up” direction in the plane
Lines are depth-sorted and drawn on top of the pixel buffer when present() / แสดงผล() / 显() / 表示() / 표시() is called.
Performance tip: vtex calls are fast (pure line rasterisation). Prefer them over
tex_*for real-time use — atex_mandelbroton a 1920×1080 window is ~2 million pixel ops per call; avtex_ringswith 32 segments is ~32 line ops.
Common plane orientations
# Horizontal plane (floor / ceiling): U=right, V=forward
1,0,0, 0,0,1
# Vertical front-facing plane (wall / mandala disc): U=right, V=up
1,0,0, 0,1,0
# Vertical side-facing plane (left/right wall): U=forward, V=up
0,0,1, 0,1,0
Primitives
vtex_grid · ลายตาราง · 纹格 · 格子模様 · 격자무늬
Rectilinear grid.
vtex_grid(cx,cy,cz, ux,uy,uz, vx,vy,vz, cols, rows, cell_w, cell_h, fr, hue)
| Param | Default | Description |
|---|---|---|
cols | — | number of columns |
rows | — | number of rows |
cell_w | — | cell width in world units |
cell_h | — | cell height in world units |
fr | — | frame counter (drives colour animation) |
hue | — | colour phase offset |
vtex_rings · ลายวงซ้อน · 纹环 · 同心円 · 동심원
Concentric N-sided polygon rings with optional twist.
vtex_rings(cx,cy,cz, ux,uy,uz, vx,vy,vz, n_rings, n_sides, max_r, twist, fr, hue)
| Param | Description |
|---|---|
n_rings | number of concentric rings |
n_sides | polygon sides per ring (32 = smooth circle) |
max_r | outer ring radius |
twist | extra rotation per ring in radians (creates vortex) |
vtex_star · ลายดาว · 纹星 · 星模様 · 별무늬
Alternating outer/inner star polygon.
vtex_star(cx,cy,cz, ux,uy,uz, vx,vy,vz, n_points, r_outer, r_inner, rot_speed, fr, hue)
vtex_spiral · ลายเกลียว · 纹螺 · 螺旋 · 나선
Archimedean spiral.
vtex_spiral(cx,cy,cz, ux,uy,uz, vx,vy,vz, n_turns, max_r, n_steps, fr, hue)
vtex_flower · ลายดอก · 纹花 · 花模様 · 꽃무늬
Flower of Life: centre circle plus 6 surrounding circles.
vtex_flower(cx,cy,cz, ux,uy,uz, vx,vy,vz, radius, n_sides, fr, hue)
vtex_lotus · ลายดอกบัว · 纹莲 · 蓮模様 · 연꽃무늬
Radial kite-petal lotus.
vtex_lotus(cx,cy,cz, ux,uy,uz, vx,vy,vz, r_inner, r_outer, n_petals, fr, hue)
vtex_chakra · ลายจักร · 纹轮 · 輪模様 · 바퀴무늬
Dhamma wheel: outer rim + inner hub + N spokes + tick marks.
vtex_chakra(cx,cy,cz, ux,uy,uz, vx,vy,vz, r, n_spokes, fr, hue)
vtex_yantra · ลายยันต์ · 纹咒 · 護符模様 · 부적무늬
Nested interlocked triangle pairs (Sri Yantra style) with bhupura gate square.
vtex_yantra(cx,cy,cz, ux,uy,uz, vx,vy,vz, n_layers, max_r, fr, hue)
vtex_spiked_cog · ฟันเฟืองหนาม · 纹棘轮 · 歯車模様 · 톱니바퀴
Mechanical gear with triangular spike teeth, inner body ring, hub, and spokes.
vtex_spiked_cog(cx,cy,cz, ux,uy,uz, vx,vy,vz,
n_teeth, r_body, r_spike, r_hub, n_spokes,
fr, hue)
| Param | Default | Description |
|---|---|---|
n_teeth | 12 | number of spike teeth |
r_body | 1.0 | radius of the flat gear body |
r_spike | 1.3 | radius of spike tips |
r_hub | 0.2 | inner hub radius |
n_spokes | 6 | spokes from hub to body |
# Example: ornate gold dharma gear
vtex_spiked_cog(0, 0, 8, 1,0,0, 0,1,0, 18, 1.6, 2.0, 0.28, 9, FR * 0.0004, 1.57)
vtex_torii · ประตูโทริอิ · 纹鸟居 · 鳥居 · 도리이
Japanese torii gate silhouette: two pillars, straight nuki crossbar, curved kasagi top beam.
vtex_torii(cx,cy,cz, ux,uy,uz, vx,vy,vz, width, height, fr, hue)
| Param | Default | Description |
|---|---|---|
width | 4.0 | total gate width |
height | 5.0 | pillar height |
# Gate on the far wall, crimson
vtex_torii(0, 0, 16, 1,0,0, 0,1,0, 6.0, 5.0, FR * 0.0001, 2.1)
vtex_pagoda · เจดีย์ · 纹塔 · 塔 · 탑
Multi-tiered pagoda silhouette with upturned eaves and spire finial.
vtex_pagoda(cx,cy,cz, ux,uy,uz, vx,vy,vz,
n_tiers, base_w, tier_h, taper, eave_out,
fr, hue)
| Param | Default | Description |
|---|---|---|
n_tiers | 5 | number of storeys |
base_w | 2.0 | half-width of base tier |
tier_h | 1.0 | height of each tier |
taper | 0.72 | width reduction per tier |
eave_out | 0.28 | eave overhang fraction |
# 5-tier gold pagoda on back wall
vtex_pagoda(0, 0, 16, 1,0,0, 0,1,0, 5, 2.2, 1.0, 0.72, 0.28, FR * 0.0001, 1.57)
vtex_halftone · ลายจุด · 纹半调 · 網点模様 · 망점
Cross-hatch dithered fill.
vtex_halftone(cx,cy,cz, ux,uy,uz, vx,vy,vz, cols, rows, cell_w, cell_h, density, fr, hue)
vtex_tessellated · ลายตาข่าย · 纹镶嵌 · 網目模様 · 격자망
Animated triangle mesh fill (sine-displaced vertices).
vtex_tessellated(cx,cy,cz, ux,uy,uz, vx,vy,vz, cols, rows, cell, amplitude, freq, fr, hue)
vtex_hyperbolic_uv · ลายไฮเพอร์โบลิก · 纹曲面 · 双曲線 · 쌍곡선
Poincaré-disc hyperbolic tiling (concentric circles + geodesic rays).
vtex_hyperbolic_uv(cx,cy,cz, ux,uy,uz, vx,vy,vz, max_r, n_circles, n_rays, fr, hue)
vtex_letter_rain · ลายอักษรไหล · 纹字雨 · 文字雨 · 글자비
Falling-glyph rain (Matrix-style, using simplified stroke glyphs).
vtex_letter_rain(cx,cy,cz, ux,uy,uz, vx,vy,vz, n_cols, n_visible, col_w, row_h, speed, fr, hue)
Colour system
All vtex functions use the cycle(phase) colour formula:
R = sin(phase) * 127 + 128
G = sin(phase + 2.094) * 127 + 128 # 120° offset
B = sin(phase + 4.189) * 127 + 128 # 240° offset
Useful hue anchor values for cultural palettes:
| Colour | hue value |
|---|---|
| Gold / amber | 1.57 (π/2) |
| Jade green | 3.50 |
| Crimson red | 2.10 |
| Ivory white | 0.30 |
| Deep blue | 4.70 |
| Purple | 5.80 |
Pixel Texture Builtins (tex_*)
tex_* functions write RGBA pixels directly to the framebuffer before the depth
queue is flushed. They are drawn underneath all vtex_* geometry.
Performance warning: Each
tex_*call iterates over every pixel in the destination rectangle. A full-screen 1920×1080 call costs ~2 million iterations. For smooth 60fps, keep tex_* calls to a small off-centre region or reduce window resolution.
All functions share the signature prefix:
tex_*(dst_x, dst_y, width, height, ...params, palette)
Palette names: "rainbow" · "fire" · "ocean" · "psychedelic" · "neon" · "forest"
tex_checkerboard · ลายตารางหมากรุก
tex_checkerboard(x, y, w, h, tiles, r1,g1,b1, r2,g2,b2)
Two-colour checker pattern. tiles = number of tiles across the width.
tex_gradient · ลายไล่สี
tex_gradient(x, y, w, h, angle_deg, r1,g1,b1, r2,g2,b2)
Linear gradient at angle_deg degrees.
tex_noise · ลายนอยส์
tex_noise(x, y, w, h, scale, octaves, seed, palette)
Fractal Brownian Motion noise.
| Param | Description |
|---|---|
scale | Noise frequency (higher = finer) |
octaves | FBM octave count (1–8) |
seed | Randomisation seed |
tex_mandelbrot · ลายแมนเดลบรอต
tex_mandelbrot(x, y, w, h, zoom, cx, cy, max_iter, palette)
| Param | Description |
|---|---|
zoom | Zoom level (1.0 = full set) |
cx, cy | Centre of view in the complex plane |
max_iter | Iteration cap (higher = more detail, slower) |
tex_julia · ลายจูเลีย
tex_julia(x, y, w, h, c_re, c_im, max_iter, palette)
Julia set with complex parameter c = c_re + i·c_im.
tex_voronoi · ลายโวโรนอย
tex_voronoi(x, y, w, h, cells, seed, palette)
tex_ripple · ลายระลอก
tex_ripple(x, y, w, h, freq, cx, cy, time, palette)
Concentric ripple emanating from (cx, cy) in normalised [0,1] coords.
tex_spiral · ลายเกลียวหมุน
tex_spiral(x, y, w, h, freq, n_bands, time, palette)
tex_halftone · ลายฮาล์ฟโทน
tex_halftone(x, y, w, h, dot_size, time, palette)
tex_freq_map · ลายความถี่
tex_freq_map(x, y, w, h, time, speed, palette)
Audio-reactive frequency bar display. Reads from the last fft_bands() call.
Call fft_push(samples) then fft_bands(n) each frame to keep it animated.
Palette reference
| Name | Description |
|---|---|
"rainbow" | Full spectrum cycle |
"fire" | Red → orange → yellow |
"ocean" | Blue → cyan → white |
"psychedelic" | High-saturation cycling |
"neon" | Bright neon green/cyan/magenta |
"forest" | Earthy greens and browns |
Audio Builtins
Audio builtins are available on native targets. On WASM they are no-ops.
Every builtin below is callable in all five languages — the aliases are accepted
by the interpreter and produced by lingfu normalize.
Multilingual names
| EN | 🇨🇳 ZH | 🇯🇵 JA | 🇰🇷 KO | 🇹🇭 TH |
|---|---|---|---|---|
audio_tone | 音调 | 音調 | 음조 | เสียงโทน |
audio_volume | 音量 | 音量 | 음량 | ระดับเสียง |
audio_listener | 音频监听 | 音声リスナー | 오디오리스너 | ผู้ฟัง |
audio_bgm | 背景乐 | BGM | 배경음악 | เพลงพื้นหลัง |
audio_bgm_volume | 背景乐音量 | BGM音量 | 배경음악음량 | ระดับเสียงพื้นหลัง |
fft_push | 频谱输入 | FFT入力 | FFT입력 | วิเคราะห์เสียง |
fft_bands | 频段 | 周波数帯 | 주파수대 | แถบความถี่ |
fft_beat | 节拍检测 | ビート検出 | 비트 | จังหวะเสียง |
fft_rms | 均方根 | 二乗平均 | RMS레벨 | ระดับRMS |
fft_dominant_freq | 主频 | 主要周波数 | 주파수 | ความถี่หลัก |
Tone synthesis
# audio_tone(slot, x, y, z, w, freq_hz, amplitude, lfo_rate, lfo_depth)
audio_tone(0, 0.0, 0.0, 8.0, 1.5, 261.63, 0.08, 0.10, 0.008)
| Param | Description |
|---|---|
slot | Tone slot index (0–15) |
x, y, z | 3D world position of the sound source |
w | Spatial spread / falloff width |
freq_hz | Oscillator frequency in Hz |
amplitude | Base amplitude (0..1) |
lfo_rate | LFO modulation rate in Hz |
lfo_depth | LFO depth (0..1) |
Volume
audio_volume(0.5) # master volume
audio_bgm_volume(0.4) # background music volume
Background music
audio_bgm("path/to/file.wav", 0.5) # load and play WAV BGM
Listener position
# Must be called each frame to update 3D audio perspective
audio_listener(cos(ry), sin(ry), cos(rx), sin(rx))
Pentatonic reference
Common frequencies for East Asian pentatonic scales:
| Note | 宫 (Gōng) | 商 (Shāng) | 角 (Jué) | 徵 (Zhǐ) | 羽 (Yǔ) |
|---|---|---|---|---|---|
| Octave 3 | C3 130.81 | D3 146.83 | E3 164.81 | G3 196.00 | A3 220.00 |
| Octave 4 | C4 261.63 | D4 293.66 | E4 329.63 | G4 392.00 | A4 440.00 |
| Octave 5 | C5 523.25 | D5 587.33 | E5 659.25 | G5 783.99 | A5 880.00 |
FFT analysis
# Push mono samples to the rolling FFT window
令 smp = list_new()
令 k = 0
循 k < 64 {
令 smp = list_push(smp, sin(k * 0.1))
令 k = k + 1
}
fft_push(smp)
# Get 32 log-spaced frequency bands (values 0..1)
令 bands = fft_bands(32)
# Beat detection
若 fft_beat() {
印("beat!")
}
令 ratio = fft_beat_ratio() # 1.0 = at threshold
令 rms = fft_rms()
令 freq = fft_dominant_freq()
Builtins — Music & Spatial Audio
ling-music is a full music layer (separate from the SFX-oriented ling-audio): decode any
common format, analyse tempo & key, synthesize GM-style instruments from .ling patches, read
MIDI, and build rhythm games & karaoke. ling-audio adds positional one-shots, sample
playback/loops, and master FX.
Playback & analysis
music_load("song.wav") → id (WAV/FLAC/OGG/MP3/AAC) · music_play(id) / music_pause /
music_stop / music_seek(sec) / music_pos() / music_volume(v) / music_duration(id) ·
music_bpm(id) · music_key(id) → e.g. "A minor" · music_onsets(id) · music_beat_grid(id) ·
music_fft(id, nbands) → spectrum at the current position (drives reactive visuals).
Synthesis (GM-capable, from .ling patches)
music_patch("instruments/rhodes_ep.ling") → inst · music_note(inst, "C4", dur, vel) ·
music_note_on(inst, pitch, vel) / music_note_off(inst, pitch). A patch is a small modular
FM/subtractive voice (operators + ADSR + filter + LFO) able to approximate any GM family.
MIDI · rhythm · karaoke
music_midi_load("song.mid") → id · music_midi_notes(id) → [time,midi,…] ·
music_midi_bars(id) → [time,midi,dur,…] (karaoke note bars) · music_midi_count(id).
music_judge(delta_ms) → grade · music_grade_name(g). music_lrc("song.lrc") /
music_lyric(id,t). music_mic_pitch() → Hz (sung pitch) · music_note_name(hz) ·
music_hz(midi) · music_pitch_score(hz, target_hz).
Spatial audio (ling-audio)
audio_tone(idx,x,y,z,w,freq,amp,lfo_rate,lfo_depth) (continuous, 3D/4D) ·
audio_sfx(x,y,z,w,freq,amp,dur,wave) (positional one-shot) ·
audio_sample_load(path) / audio_sample_play(id,x,y,z,w,vol,loop) / audio_sample_stop(v) ·
audio_listener(cry,sry,crx,srx) (match the camera) · audio_volume(v) ·
master FX: audio_fx_delay(time,fb,mix) · audio_fx_reverb(mix) · audio_fx_lowpass(cutoff)
(1.0 = open, lower = muffled/underwater).
See examples/music/{synth_jam,rhythm_game,karaoke_hero,hallway_runner}.ling. Full
implemented-vs-missing list: docs/AUDIO_MUSIC_TODO.md.
Builtins — Vector Fonts
Ling renders real TrueType/OpenType fonts as resolution-independent vectors. The first time
a glyph is used its outline is extracted and cached as cache/fonts/<font>/<codepoint>.ling
(curves preserved), then rendered crisp — stroked or filled, with anti-aliasing — at any size
and in 2D or 3D/4D.
| Builtin | Meaning |
|---|---|
font_load(path [, weight]) → handle | Load a TTF/OTF; optional variable-font weight (e.g. 600 for bold). Returns -1 on failure. |
font_text(handle, x, y, px, "text") | Anti-aliased stroked outline in the current set_color/set_blend. |
font_text_fill(handle, x, y, px, "text") | Anti-aliased filled glyphs (solid letterforms). |
font_text_3d(handle, cx,cy,cz, ux,uy,uz, vx,vy,vz, size, "text") | Stroked text on a 3-D plane (basis u,v), depth-sorted — rotates with the camera and projects through the 4-D pipeline. |
font_width(handle, px, "text") | Pixel width of a string. |
Any script is covered: Latin, 中文, 日本語, 한국어, ไทย all render from the right font (e.g. Noto Sans SC covers Latin + CJK + Thai).
bind f = font_load("assets/fonts/Exo2.ttf", 600.0)
set_color(0, 230, 255)
font_text_fill(f, 40.0, 30.0, 36.0, "LING 灵")
font_text_3d(f, 0.0,0.0,0.0, 1.0,0.0,0.0, 0.0,-1.0,0.0, 0.6, "3D TEXT")
Related: project_3d(x,y,z) → [sx,sy,depth] and draw_poly([x0,y0,…]) (filled 2-D polygon,
blend-aware) let you place filled vector shapes onto projected 3-D points.
Builtins — UI Toolkit
A vector, theme-coloured immediate-mode widget library (HUD, meters, interface controls, game
UI, plus a few faux-3D widgets). All widgets are drawn each frame; interactive ones read the
mouse and return their state. Set the palette once with ui_theme; every widget takes an
optional trailing r,g,b to override its main colour.
ui_theme(0,210,255, 60,255,180, 40,60,95, 255,90,90, 190,235,255, 10,16,24)
HUD / sci-fi overlays
ui_radar(cx,cy,r,sweep) · ui_compass(x,y,w,h,heading) · ui_reticle(cx,cy,r,spread) ·
ui_target(x,y,w,h,lock) · ui_panel(x,y,w,h,bevel) · ui_scanlines(x,y,w,h,density)
Meters & gauges
ui_bar(x,y,w,h,value,max) · ui_segbar(…,segs) · ui_gauge(cx,cy,r,value,max) ·
ui_ring(cx,cy,r,value,max) · ui_vu(x,y,w,h,levels_list) · ui_spark(x,y,w,h,values_list) ·
ui_battery(x,y,w,h,value,max)
Interface controls (interactive — return state)
ui_button(x,y,w,h) → 1 when clicked · ui_toggle(x,y,w,h,state) → new state ·
ui_slider(x,y,w,value,min,max) → new value · ui_checkbox(x,y,size,checked) → new checked ·
ui_tabs(x,y,w,h,count,active) → active index · ui_progress(x,y,w,h,frac) ·
ui_tooltip(x,y,w,h) · ui_stepper(x,y,w,h,value,step) → new value
Game UI
ui_healthbar(x,y,w,h,hp,max,pulse) · ui_cooldown(cx,cy,r,frac) ·
ui_counter(x,y,dw,dh,value,digits) (7-segment) · ui_minimap(x,y,w,h) ·
ui_dpad(cx,cy,r) → direction · ui_slotgrid(x,y,cols,rows,cell,sel) ·
ui_vignette(intensity, r,g,b)
Faux-3D in 2D space
ui_gauge3d(cx,cy,r,value,spin) · ui_panel3d(x,y,w,h,depth) · ui_radar3d(cx,cy,r,tilt,sweep)
Interface sounds
ui_sound("click"|"hover"|"confirm"|"error"|"toggle"|"tick") · audio_blip(freq,dur,wave,amp)
See examples/ui/hud_showcase.ling.
Builtins — Physics
Ling exposes the ling-physics engine to scripts: rigid bodies with angular dynamics,
deformable soft bodies, and a fast 2-D immiscible liquid simulation that maps onto 3-D
surfaces. Every builtin has aliases in all five languages (see
Builtin Aliases by Language).
Coordinate note: in the renderer +y points down, so “gravity” is a positive y value.
Soft bodies (deformable / bouncy)
A spring-mass sphere that squashes and stretches on impact.
| Builtin | Meaning |
|---|---|
soft_ball(x, y, z, r) → id | Create a deformable ball at (x,y,z) radius r. |
soft_step(id, dt, gravity) | Advance the body dt seconds under gravity (y). |
soft_bounce(id, floor_y, restitution) | Bounce nodes off a horizontal floor. |
soft_contain(id, minx,miny,minz, maxx,maxy,maxz, restitution) | Keep the body inside a box, bouncing (squashing) off every wall. |
soft_kick(id, dx, dy, dz, strength) | Impulse the whole body along a direction. |
soft_deform(id) → f | Deformation factor 0 (round) … 1 (squished). |
soft_centroid(id) → [x,y,z] | Centre of mass. |
soft_nodes(id) → [x,y,z, …] | Flat list of every mesh node — draw it to show the deformed surface. |
bind ball = soft_ball(0.0, 0.0-2.5, 0.0, 1.2)
while window_is_open() {
soft_step(ball, 0.016, 9.0)
soft_contain(ball, 0.0-4.0,0.0-4.0,0.0-4.0, 4.0,4.0,4.0, 0.55)
bind ns = soft_nodes(ball) # draw the squashing mesh
# … render nodes …
}
See examples/physics/bouncy_ball.ling.
Rigid bodies + angular dynamics
A shared rigid-body world with torque, spin, inertia and a spin-inducing floor bounce, so bodies tumble and roll.
| Builtin | Meaning |
|---|---|
rb_add(x, y, z, mass) → i | Add a body, returns its index. |
rb_gravity(gx, gy, gz) | Set world gravity. |
rb_torque(i, tx, ty, tz) | Apply torque (world axes). |
rb_spin(i, wx, wy, wz) | Add to angular velocity. |
rb_impulse(i, ix, iy, iz) | Apply a linear impulse. |
rb_floor(i, y, restitution, friction) | Bounce off a floor; friction converts motion into roll/spin. |
rb_step(dt) | Step the whole world (integrate + collide). |
rb_pos(i) → [x,y,z] | Body position. |
rb_rot(i) → [qx,qy,qz,qw] | Body orientation quaternion (rotate your mesh by it). |
See examples/physics/tumbling.ling (cubes rotated by rb_rot).
Liquid simulation (water + oil)
Two immiscible density fields advected by one incompressible velocity grid. The fluids only
blend at their interface, so the physics decides where the blue (water) and amber (oil) colours
mix. Built for speed; wrap makes it seamless for mapping onto curved surfaces.
| Builtin | Meaning |
|---|---|
liquid_new(w, h) → id | Create a w×h fluid grid. |
liquid_splat(id, x, y, kind, amount, radius) | Add fluid (kind 0 = water, 1 = oil) in a disc. |
liquid_gravity(id, gx, gy) | Set the gravity vector (rotate it to slosh). |
liquid_step(id, dt) | Advance the simulation. |
liquid_draw(id, x, y, scale) | Fast flat 2-D blit of the colour field. |
liquid_draw_surface(id, kind, cx,cy,cz, radius, height) | Map/wrap the field onto a 3-D surface — kind: 0 plane · 1 sphere · 2 cylinder · 3 cone · 4 dome. |
bind liq = liquid_new(84.0, 84.0)
liquid_splat(liq, 42.0, 25.0, 1.0, 1.0, 3.0) # oil
liquid_splat(liq, 42.0, 58.0, 0.0, 1.0, 3.0) # water
while window_is_open() {
liquid_gravity(liq, sin(time_now())*55.0, cos(time_now())*55.0)
liquid_step(liq, 0.016)
set_camera(cos(time_now()*0.3), sin(time_now()*0.3), cos(0.4), sin(0.4))
liquid_draw_surface(liq, 1.0, 0.0,0.0,0.0, 2.2, 3.2) # onto a sphere
present()
}
See examples/physics/liquid_marble.ling.
Window & Camera Builtins
Every builtin below is callable in all five languages — the aliases listed are
accepted by the interpreter and produced by lingfu normalize, so a program
written (or normalized) in any language runs unchanged.
Window · 2-D drawing
| EN | 🇨🇳 ZH | 🇯🇵 JA | 🇰🇷 KO | 🇹🇭 TH | Description |
|---|---|---|---|---|---|
open_window | 开窗 | ウィンドウ開く | 창열기 | เปิดหน้าต่าง | Open a window |
open_fullscreen | 全屏 | 全画面 | 전체화면 | เปิดหน้าต่างเต็มจอ | Open fullscreen window |
window_is_open | 窗开 | 開いている | 창열림 | หน้าต่างเปิดอยู่ | True while window is open |
get_width | 宽 | 幅取得 | 너비 | ความกว้าง | Window width (px) |
get_height | 高 | 高取得 | 높이 | ความสูง | Window height (px) |
fill / clear | 填 / 清 | 塗り潰し / 消去 | 채우기 / 지우기 | เติม | Clear screen to RGB |
set_color | 设色 | 色設定 | 색설정 | สีดินสอ | Set pen colour |
set_color_hsl | 色相 | HSL色 | HSL색설정 | สีHSLวาด | Set pen colour via HSL |
draw_line | 画线 | 線描く | 선그리기 | วาดเส้น | Draw a 2-D line |
draw_pixel | 画点 | 点描く | 점그리기 | วาดจุด | Plot a pixel |
triangle | 画三角 | 三角形描画 | 삼각형그리기 | วาดสามเหลี่ยม | Fill a 2-D triangle |
present | 显 | 表示 | 표시 | แสดงผล | Flush depth queue → screen |
capture_mouse | 捕鼠 | マウス捕捉 | 마우스잡기 | จับเมาส์ | Lock mouse to window |
See also draw_circle / draw_disc / set_blend (procedural set).
Input
| EN | 🇨🇳 ZH | 🇯🇵 JA | 🇰🇷 KO | 🇹🇭 TH | Description |
|---|---|---|---|---|---|
key_down | 按键 | キー押す | 키누름 | กดค้าง | True while key held |
key_pressed | 键按 | キー押した | 키눌림 | กดปุ่ม | True on key-press edge |
mouse_dx | 鼠ΔX | マウスΔX | 마우스ΔX | เมาส์X | Mouse delta X |
mouse_dy | 鼠ΔY | マウスΔY | 마우스ΔY | เมาส์Y | Mouse delta Y |
Camera
| EN | 🇨🇳 ZH | 🇯🇵 JA | 🇰🇷 KO | 🇹🇭 TH | Description |
|---|---|---|---|---|---|
set_camera | 设镜 | カメラ設定 | 카메라설정 | ตั้งกล้อง | Orient camera (yaw/pitch) |
set_camera_pos | 镜坐标 | カメラ座標 | 카메라좌표 | ตั้งตำแหน่งกล้อง | Position camera |
set_zdist | 镜距 | Z距離設定 | Z거리설정 | ตั้งระยะห่าง | Near-plane distance |
set_projection | 投影 | 投影設定 | 투영설정 | ตั้งโปรเจกชัน | Set projection mode |
Lighting
| EN | 🇨🇳 ZH | 🇯🇵 JA | 🇰🇷 KO | 🇹🇭 TH | Description |
|---|---|---|---|---|---|
set_ambient | 环境光 | 環境光設定 | 환경광설정 | ตั้งแสงรอบข้าง | Ambient level 0–1 |
add_light | 加灯 | ライト追加 | 조명추가 | เพิ่มแสง | Add a point light |
clear_lights | 清灯 | ライト消去 | 조명초기화 | ล้างแสง | Remove all lights |
# Orient camera by yaw (ry) and pitch (rx) angles
set_camera(cos(ry), sin(ry), cos(rx), sin(rx))
set_camera_pos(x, y, z)
set_zdist(d)
Camera
# Orient camera by yaw (ry) and pitch (rx) angles
set_camera(cos(ry), sin(ry), cos(rx), sin(rx))
# Position camera in world space
set_camera_pos(x, y, z)
# Set near-plane distance (default 2.0)
set_zdist(d)
Lighting
# Remove all lights
clear_lights()
# Add a point light
# add_light(x, y, z, r, g, b, intensity, radius)
add_light(0, 4, 8, 1.0, 0.85, 0.3, 2.5, 16.0)
# Ambient level (0.0–1.0)
set_ambient(0.1)
Pen colour (for 2D drawing)
# Set pen colour for subsequent 2D draws
สีดินสอ(r, g, b) # or: pen_color(r,g,b)
Typical main loop structure
令 启 = 执 {
เปิดหน้าต่างเต็มจอ("My Scene")
capture_mouse()
set_ambient(0.10)
令 帧 = 0
循 หน้าต่างเปิดอยู่() {
เติม(0, 0, 0) # clear to black
# update camera
set_camera(cos(ry), sin(ry), cos(rx), sin(rx))
set_camera_pos(cx, cy, cz)
set_zdist(2.0)
# draw geometry
clear_lights()
add_light(...)
vtex_grid(...)
vtex_rings(...)
แสดงผล() # flush
令 帧 = 帧 + 1
}
}
Keyword Aliases by Language
Every keyword in Ling works in all supported languages simultaneously. You can mix languages freely within a single source file.
Core keyword table
| Token | English | Chinese 中文 | Japanese 日本語 | Korean 한국어 | Thai ไทย | Russian | Arabic | Spanish | French | German | Hindi | Portuguese |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Bind | bind | 令 灵符 | 束縛 バ | 바인드 묶 | ผูก | связать | ربط | enlazar | lier | binden | बाँधो | ligar |
| Do | do | 执 | 実行 執 | 실행 | ทำ | сделать | افعل | hacer | faire | machen | करो | fazer |
| Function | fn | 函 | 関数 関 | 함수 | ฟังก์ชัน | — | — | — | func | — | — | — |
| If | if | 若 如 | もし | 만약 조건 | ถ้า | если | إذا | si | — | wenn | अगर | se |
| Else | else | 否则 否 | 他 | 아니면 | มิฉะนั้น | иначе | وإلا | sino | sinon | sonst | नहींतो | senão |
| While | while | 循 当 | 間 一方 | 동안 반복 | ขณะที่ | пока | بينما | mientras | tantque | solange | जबकि | enquanto |
| For | for | 历 | 繰 ために | 위해 | สำหรับ | для | لأجل | para | — | für | केलिए | — |
| In | in | 于 | の中 | 안에 | ใน | — | في | — | — | — | — | — |
| Return | return | 归 | 戻る 帰る | 반환 귀환 | คืน | вернуть | أعد | retornar | retourner | zurück | वापस | — |
| Match | match | 配 | 一致 | 매치 | จับคู่ | — | — | — | — | — | — | — |
| Try | try | 试 | 試す | 시도 | — | — | — | — | — | — | — | — |
| Module | mod | 核 | モジュール 模 | 모듈 | โมดูล | — | — | — | module | — | — | — |
| Spawn | spawn | 启 | 起動 | 생성 | — | — | — | — | — | — | — | — |
| Stop | stop | 止 | 停止 | 멈춤 | — | — | — | — | — | — | — | — |
| Continue | again | 继续 | 継続 | 계속 | — | — | — | — | — | — | — | — |
| Async | async | 异步 异 | 非同期 | 비동기 | ไม่พร้อมกัน | — | — | — | — | — | — | — |
| Wait | wait | 待 | 待つ | 기다려 | รอ | — | — | — | — | — | — | — |
| True | true | 真 | — | 참 | จริง | — | صحيح | verdadero | vrai | wahr | सत्य | verdadeiro |
| False | false | 假 偽 | — | 거짓 | เท็จ | — | خطأ | falso | faux | falsch | असत्य | — |
Entry point forms by language
The program entry point 令 启 = 执 { ... } in different languages:
# Chinese
令 启 = 执 { ... }
# Thai
ผูก เริ่ม = ทำ { ... }
# English
bind start = do { ... }
# Korean
바인드 시작 = 실행 { ... }
# Japanese
束縛 スタート = 実行 { ... }
# Russian
связать начало = сделать { ... }
# Arabic
ربط ابدأ = افعل { ... }
# Spanish
enlazar inicio = hacer { ... }
# German
binden anfang = machen { ... }
# Hindi
बाँधो शुरू = करो { ... }
Function definition forms
# Chinese
函 add(a, b) { 归 a + b }
# Thai
ฟังก์ชัน add(a, b) { คืน a + b }
# English
fn add(a, b) { return a + b }
# Korean
함수 더하기(a, b) { 반환 a + b }
Loop forms
# Chinese while loop
令 i = 0
循 i < 10 {
令 i = i + 1
}
# Thai while loop
ให้ i = 0
ขณะที่ i < 10 {
ให้ i = i + 1
}
# English while loop
bind i = 0
while i < 10 {
bind i = i + 1
}
Builtin Aliases by Language
Every builtin function has at least one Thai alias and one English alias. All aliases listed here are valid in the same source file simultaneously.
Output
| English | Thai | Chinese | Description |
|---|---|---|---|
print(v) | พิมพ์(v) | 印(v) | Print value |
println(v) | พิมพ์(v) | 印(v) | Print with newline |
format(fmt, ...) | รูปแบบ(...) | 格式(...) | Format string |
Math
| English | Thai | Description |
|---|---|---|
sin(x) | ไซน์(x) | Sine |
cos(x) | โคไซน์(x) | Cosine |
tan(x) | แทนเจนต์(x) | Tangent |
asin(x) arcsin(x) | — | Arcsine |
acos(x) arccos(x) | — | Arccosine |
atan(x) arctan(x) | — | Arctangent |
atan2(y,x) | — | 2-argument arctangent |
sqrt(x) | รากที่สอง(x) | Square root |
pow(x,y) | ยกกำลัง(x,y) | Power |
log(x) ln(x) | ลอการิทึม(x) | Natural logarithm |
exp(x) | — | e^x |
abs(x) | ค่าสัมบูรณ์(x) | Absolute value |
floor(x) | ปัดลง(x) | Floor |
ceil(x) | ปัดขึ้น(x) | Ceiling |
round(x) | ปัดเศษ(x) | Round |
trunc(x) int(x) | ตัดทศนิยม(x) | Truncate to integer |
min(a,b) | ต่ำสุด(a,b) | Minimum |
max(a,b) | สูงสุด(a,b) | Maximum |
clamp(v,lo,hi) | จำกัด(v,lo,hi) | Clamp to range |
tanh(x) | — | Hyperbolic tangent |
Window & display
| English | Thai | Description |
|---|---|---|
open_window(title) | เปิดหน้าต่าง(title) | Open window |
open_fullscreen(title) | เปิดหน้าต่างเต็มจอ(title) | Open fullscreen |
window_is_open() | หน้าต่างเปิดอยู่() | Poll window open state |
fill(r,g,b) | เติม(r,g,b) | Clear screen |
display() present() | แสดงผล() | Flush to screen |
get_width() | ความกว้าง() | Window width in pixels |
get_height() | ความสูง() | Window height in pixels |
capture_mouse() | จับเมาส์() | Lock cursor |
wait_window() | รอหน้าต่าง() | Block until window closes |
set_color(r,g,b) | สีดินสอ(r,g,b) | Set pen colour |
Camera
| English | Thai | Description |
|---|---|---|
set_camera(cry,sry,crx,srx) | ตั้งกล้อง(...) | Orient camera |
set_camera_pos(x,y,z) | ตั้งตำแหน่งกล้อง(x,y,z) | Move camera |
set_zdist(d) | ตั้งระยะห่าง(d) | Set near-plane distance |
Lighting
| English | Thai | Description |
|---|---|---|
add_light(x,y,z, r,g,b, intensity, radius) | เพิ่มแสง(...) | Add point light |
clear_lights() | ล้างแสง() | Remove all lights |
set_ambient(level) | ตั้งแสงรอบข้าง(level) | Ambient light level |
Vector geometry (vtex)
All names in the same row are valid aliases for the same function.
| English | Thai | Chinese | Japanese | Korean | Description |
|---|---|---|---|---|---|
vtex_grid | ลายตาราง | 纹格 | 格子模様 | 격자무늬 | Rectilinear grid |
vtex_rings | ลายวงซ้อน | 纹环 | 同心円 | 동심원 | Concentric rings |
vtex_star | ลายดาว | 纹星 | 星模様 | 별무늬 | Star polygon |
vtex_spiral | ลายเกลียว | 纹螺 | 螺旋 | 나선 | Archimedean spiral |
vtex_flower | ลายดอก | 纹花 | 花模様 | 꽃무늬 | Flower of Life |
vtex_lotus | ลายดอกบัว | 纹莲 | 蓮模様 | 연꽃무늬 | Lotus petals |
vtex_chakra | ลายจักร | 纹轮 | 輪模様 | 바퀴무늬 | Dhamma wheel |
vtex_yantra | ลายยันต์ | 纹咒 | 護符模様 | 부적무늬 | Sri Yantra |
vtex_spiked_cog | ฟันเฟืองหนาม | 纹棘轮 | 歯車模様 | 톱니바퀴 | Spiked gear |
vtex_torii | ประตูโทริอิ | 纹鸟居 | 鳥居 | 도리이 | Torii gate |
vtex_pagoda | เจดีย์ | 纹塔 | 塔 | 탑 | Pagoda silhouette |
vtex_halftone | ลายจุด | 纹半调 | 網点模様 | 망점 | Cross-hatch fill |
vtex_tessellated | ลายตาข่าย | 纹镶嵌 | 網目模様 | 격자망 | Triangle mesh fill |
vtex_hyperbolic_uv | ลายไฮเพอร์โบลิก | 纹曲面 | 双曲線 | 쌍곡선 | Hyperbolic tiling |
vtex_letter_rain | ลายอักษรไหล | 纹字雨 | 文字雨 | 글자비 | Glyph rain |
Pixel textures (tex)
| English | Thai | Description |
|---|---|---|
tex_checkerboard(...) | ลายตารางหมากรุก(...) | Checker pattern |
tex_gradient(...) | ลายไล่สี(...) | Linear gradient |
tex_noise(...) | ลายนอยส์(...) | FBM noise |
tex_mandelbrot(...) | ลายแมนเดลบรอต(...) | Mandelbrot fractal |
tex_julia(...) | ลายจูเลีย(...) | Julia fractal |
tex_voronoi(...) | ลายโวโรนอย(...) | Voronoi cells |
tex_ripple(...) | ลายระลอก(...) | Ripple / interference |
tex_spiral(...) | ลายเกลียวหมุน(...) | Pixel spiral |
tex_halftone(...) | ลายฮาล์ฟโทน(...) | Halftone dots |
tex_freq_map(...) | ลายความถี่(...) | FFT frequency bars |
Audio
| English | Thai | Description |
|---|---|---|
audio_tone(slot,x,y,z,w, freq,amp,lfo,depth) | เสียงโทน(...) | Spatial tone synth |
audio_volume(v) | ระดับเสียง(v) | Master volume |
audio_bgm(path,vol) | เพลงพื้นหลัง(path,vol) | Background music |
audio_bgm_volume(v) | ระดับเสียงพื้นหลัง(v) | BGM volume |
audio_listener(cry,sry,crx,srx) | ผู้ฟัง(...) | Listener orientation |
FFT (native only)
| English | Thai | Description |
|---|---|---|
fft_push(samples) | วิเคราะห์เสียง(samples) | Feed samples to analyzer |
fft_bands(n) | แถบความถี่(n) | Get n frequency bands |
fft_beat() | จังหวะเสียง() | Beat detection |
fft_beat_ratio() | อัตราจังหวะ() | Beat strength ratio |
fft_rms() | ระดับRMS() | RMS level |
fft_dominant_freq() | ความถี่หลัก() | Peak frequency in Hz |
Lists
| English | Description |
|---|---|
list_new() | Create empty list |
list_push(lst, v) | Append and return new list |
list_pop(lst) | Remove last element |
list_get(lst, i) | Get element at index |
list_set(lst, i, v) | Set element at index |
list_len(lst) | Number of elements |
Strings
| English | Thai | Description |
|---|---|---|
split(s, delim) str_split(s, delim) | แยก(s, delim) | Split string |
trim(s) str_trim(s) | ตัดช่องว่าง(s) | Trim whitespace |
starts_with(s, prefix) | เริ่มด้วย(s, prefix) | Prefix test |
str_len(s) | — | String length |
str_concat(a,b) | — | Concatenate |
num_to_str(n) | — | Number to string |
str_to_num(s) | — | Parse number |
File I/O
| English | Thai | Description |
|---|---|---|
read_file(path) | อ่านไฟล์(path) | Read file to string |
write_file(path, content) | เขียนไฟล์(path, content) | Write string to file |
Input
| English | Thai | Description |
|---|---|---|
key_down(key) | กดค้าง(key) | True while key held |
key_pressed(key) | กดปุ่ม(key) | True on key press event |
mouse_dx() | เมาส์X() | Mouse X delta |
mouse_dy() | เมาส์Y() | Mouse Y delta |
道场 — Shrine Room
Source: examples/3d-rooms/ling-dao-chamber.ling
A quiet Chinese-Japanese temple rendered entirely with vector geometry (vtex_*).
No pixel fills. Slow, dignified motion in a gold · jade · crimson palette.
Features demonstrated:
vtex_torii— torii gatevtex_pagoda— five-tier pagodavtex_spiked_cog— gear mandala altarvtex_chakra+vtex_lotus— dharma-wheel mandala- Pentatonic bell-circle audio with spatial 3D positioning
- Pendulum camera orbit
Run with:
ling examples/3d-rooms/ling-dao-chamber.ling
Garden
Source: examples/audiovisual/Garden.ling
An outdoor garden scene with flowing organic geometry.
Run with:
ling examples/audiovisual/Garden.ling
Hyperbolic World — an H²×ℝ block walker
examples/physics/hyperbolic_world.ling is a tiny game world inspired by
Hypermine. Hypermine is set in H³
(fully 3-D hyperbolic space); this demo uses the simplest playable cousin,
H²×ℝ: you walk on the hyperbolic plane (the Poincaré disk) with ordinary
vertical gravity.
ling run examples/physics/hyperbolic_world.ling
Controls
| Key | Action |
|---|---|
W / S | walk forward / back |
A / D | strafe left / right |
Q / E | turn left / right |
SPACE | jump (gravity pulls you back down) |
What makes it hyperbolic
- Exponential crowding. Blocks are placed on a lattice of growing rings;
because the plane is hyperbolic, ever more cells pile up toward the horizon
(the disk boundary = infinity) and shrink via the Poincaré conformal factor
1 − |z|². - Möbius locomotion. You stay at the disk centre and the whole world slides
under you by a Möbius translation
z ↦ (z + a)/(1 + ā z). Turning is a rotation about the centre. - Holonomy. Walk a closed loop and you come back rotated — the signature effect of moving through negatively-curved space. (Try strafing in a square.)
- Gravity acts on the ordinary vertical axis (the ℝ factor), so jumping and falling feel completely normal even though the ground is hyperbolic.
Procedural block “textures”
Each cell hashes its lattice id (fract(sin(...))) into a block type
(grass / stone / dirt / crystal) and a height, so the world is generated
without any texture assets — the colour is the procedural texture, shaded with
the holographic cel renderer.
Notes & ideas
- The blocks are drawn with the
cubeprimitive; swap inprism,cylinder, oricosahedronfor different tilings. - Increase the ring count or
cells = 6 * ringfor a denser world. - This is H²×ℝ, not full H³ — a true Hypermine-style H³ voxel engine would
track an
{p,q,r}honeycomb and node graph, which is a much larger build.