Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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

CrateVersionPurpose
ling-lang2030.1.3Main interpreter binary
ling-core2030.0.0Core types
ling-audio2030.0.04D audio + FFT
ling-game2030.0.0ECS, mesh, physics
ling-graphics2030.0.03D/4D rendering
ling-crypto2030.0.0Cryptography
ling-net2030.0.0Async networking
ling-ai2030.0.0LLM / 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 .ling glyph 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 .ling patch, 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.

CapabilityLingUnityGodotBevy (Rust)Pygamep5.jsLÖ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~5many~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

DemoWhat it shows
examples/music/hallway_runner.lingAuto-playing FFT-reactive infinite runner; MIDI-driven coins ring the melody as spatial SFX
examples/music/karaoke_hero.lingKaraoke-Hero pitch bars from a vocal MIDI + live mic tuner
examples/music/synth_jam.lingGM instruments synthesized from .ling patches
examples/physics/bouncy_ball.lingSpring-mass soft body squashing as it bounces
examples/physics/tumbling.lingRigid bodies tumbling & rolling (angular dynamics)
examples/physics/liquid_marble.lingWater+oil sim mapped onto a spinning sphere/cone/dome
examples/ui/hud_showcase.lingThe full vector UI toolkit (HUD, meters, controls, game UI)
examples/crypto/crypto_donut_physics.lingA 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 - x instead 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🇹🇭 THDescription
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🇹🇭 THDescription
sin正弦サイン사인ไซน์Sine
cos余弦コサイン코사인โคไซน์Cosine
tan正切タンジェント탄젠트แทนเจนต์Tangent
asin反正弦アークサイン아크사인อาร์กไซน์Arcsine
acos反余弦アークコサイン아크코사인อาร์กโคไซน์Arccosine
atan反正切アークタンジェント아크탄젠트อาร์กแทนเจนต์Arctangent
atan2反正切2アークタンジェント2아크탄젠트2Two-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 / 로그10Base-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 in TODO.md.

Lists

EN🇨🇳 ZH🇯🇵 JA🇰🇷 KO🇹🇭 THDescription
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

FunctionDescription
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

FunctionReturns
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)

FunctionDescription
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)
GroupParamsMeaning
Centrecx, cy, czworld-space position of the shape’s centre
Scalesx, sy, szper-axis size (half-extent). Non-uniform values give stretched cubes, ellipsoids, flat discs, …
Rotationrx, ry, rzEuler rotation in radians, applied X → Y → Z
Modemode0 = filled · 1 = wireframe · 2 = both (wire drawn on top)
Extrase0, e1, e2shape-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

modeResult
0Filled — cel-lit triangles
1Wireframe — edges only, in the pen colour
2Both — 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.

BuiltinArgsEffect
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–255tint of unlit regions (coloured shadows)
set_rim(strength, r,g,b)strength + 0–255Fresnel 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.

BuiltinDieAliases
tetrahedrond4d4 · 四面体 · 정사면체 · ทรงสี่หน้า
cubed6(see above)
octahedrond8d8 · 八面体 · 정팔면체 · ทรงแปดหน้า
dodecahedrond12d12 · 十二面体 · 정십이면체 · ทรงสิบสองหน้า
icosahedrond20d20 · 二十面体 · 정이십면체 · ทรงยี่สิบหน้า
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: cylinder with a small sy (e.g. 0.05).
  • Ellipsoid: sphere with unequal sx,sy,sz.
  • Obelisk: frustum with a small top_ratio and tall sy.
  • Animate by feeding the frame counter into rx,ry,rz each frame.
  • Outlined solid: use mode = 2 and 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 — a tex_mandelbrot on a 1920×1080 window is ~2 million pixel ops per call; a vtex_rings with 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)
ParamDefaultDescription
colsnumber of columns
rowsnumber of rows
cell_wcell width in world units
cell_hcell height in world units
frframe counter (drives colour animation)
huecolour 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)
ParamDescription
n_ringsnumber of concentric rings
n_sidespolygon sides per ring (32 = smooth circle)
max_router ring radius
twistextra 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)
ParamDefaultDescription
n_teeth12number of spike teeth
r_body1.0radius of the flat gear body
r_spike1.3radius of spike tips
r_hub0.2inner hub radius
n_spokes6spokes 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)
ParamDefaultDescription
width4.0total gate width
height5.0pillar 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)
ParamDefaultDescription
n_tiers5number of storeys
base_w2.0half-width of base tier
tier_h1.0height of each tier
taper0.72width reduction per tier
eave_out0.28eave 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:

Colourhue value
Gold / amber1.57 (π/2)
Jade green3.50
Crimson red2.10
Ivory white0.30
Deep blue4.70
Purple5.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.

ParamDescription
scaleNoise frequency (higher = finer)
octavesFBM octave count (1–8)
seedRandomisation seed

tex_mandelbrot · ลายแมนเดลบรอต

tex_mandelbrot(x, y, w, h,  zoom, cx, cy, max_iter, palette)
ParamDescription
zoomZoom level (1.0 = full set)
cx, cyCentre of view in the complex plane
max_iterIteration 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

NameDescription
"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)
ParamDescription
slotTone slot index (0–15)
x, y, z3D world position of the sound source
wSpatial spread / falloff width
freq_hzOscillator frequency in Hz
amplitudeBase amplitude (0..1)
lfo_rateLFO modulation rate in Hz
lfo_depthLFO 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 3C3 130.81D3 146.83E3 164.81G3 196.00A3 220.00
Octave 4C4 261.63D4 293.66E4 329.63G4 392.00A4 440.00
Octave 5C5 523.25D5 587.33E5 659.25G5 783.99A5 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.

BuiltinMeaning
font_load(path [, weight]) → handleLoad 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.

BuiltinMeaning
soft_ball(x, y, z, r) → idCreate 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) → fDeformation 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.

BuiltinMeaning
rb_add(x, y, z, mass) → iAdd 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.

BuiltinMeaning
liquid_new(w, h) → idCreate 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🇹🇭 THDescription
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🇹🇭 THDescription
key_down按键キー押す키누름กดค้างTrue while key held
key_pressed键按キー押した키눌림กดปุ่มTrue on key-press edge
mouse_dx鼠ΔXマウスΔX마우스ΔXเมาส์XMouse delta X
mouse_dy鼠ΔYマウスΔY마우스ΔYเมาส์YMouse delta Y

Camera

EN🇨🇳 ZH🇯🇵 JA🇰🇷 KO🇹🇭 THDescription
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🇹🇭 THDescription
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

TokenEnglishChinese 中文Japanese 日本語Korean 한국어Thai ไทยRussianArabicSpanishFrenchGermanHindiPortuguese
Bindbind 灵符束縛 바인드 ผูกсвязатьربطenlazarlierbindenबाँधोligar
Dodo実行 실행ทำсделатьافعلhacerfairemachenकरोfazer
Functionfn関数 함수ฟังก์ชันfunc
Ifif もし만약 조건ถ้าеслиإذاsiwennअगरse
Elseelse否则 아니면มิฉะนั้นиначеوإلاsinosinonsonstनहींतोsenão
Whilewhile 一方동안 반복ขณะที่покаبينماmientrastantquesolangeजबकिenquanto
Forfor ために위해สำหรับдляلأجلparafürकेलिए
Ininの中안에ในفي
Returnreturn戻る 帰る반환 귀환คืนвернутьأعدretornarretournerzurückवापस
Matchmatch一致매치จับคู่
Trytry試す시도
Modulemodモジュール 모듈โมดูลmodule
Spawnspawn起動생성
Stopstop停止멈춤
Continueagain继续継続계속
Asyncasync异步 非同期비동기ไม่พร้อมกัน
Waitwait待つ기다려รอ
Truetrueจริงصحيحverdaderovraiwahrसत्यverdadeiro
Falsefalse 거짓เท็จخطأfalsofauxfalschअसत्य

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

EnglishThaiChineseDescription
print(v)พิมพ์(v)印(v)Print value
println(v)พิมพ์(v)印(v)Print with newline
format(fmt, ...)รูปแบบ(...)格式(...)Format string

Math

EnglishThaiDescription
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

EnglishThaiDescription
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

EnglishThaiDescription
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

EnglishThaiDescription
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.

EnglishThaiChineseJapaneseKoreanDescription
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)

EnglishThaiDescription
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

EnglishThaiDescription
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)

EnglishThaiDescription
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

EnglishDescription
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

EnglishThaiDescription
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

EnglishThaiDescription
read_file(path)อ่านไฟล์(path)Read file to string
write_file(path, content)เขียนไฟล์(path, content)Write string to file

Input

EnglishThaiDescription
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 gate
  • vtex_pagoda — five-tier pagoda
  • vtex_spiked_cog — gear mandala altar
  • vtex_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 (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

KeyAction
W / Swalk forward / back
A / Dstrafe left / right
Q / Eturn left / right
SPACEjump (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 cube primitive; swap in prism, cylinder, or icosahedron for different tilings.
  • Increase the ring count or cells = 6 * ring for 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.