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

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
    }
}