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

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