code wiki / (root) / nx_garment_twin.nx

nx_garment_twin.nx

buildroot/runtime/nx_garment_twin.nx

9862 B186 linesdepth 11pulls 52 transitivereach 0 importersview sourcekind tooltopic garment
docsdependenciesstructsconstsfunctions

about

nx_garment_twin.nx -- THE GARMENT PREVIEW: a print placed on a lit, procedurally knitted cotton front (2026-08-24, /compare/phototwin PT5: gt_print_place). license_tier: ORIGINAL No hw writes (Rule 26). nx_garment_twin place <print.img> <out.png> [conf] -> the flat-front preview PNG + a stats line + verdict=PLACED EXIT: 0 PLACED | 2 usage | 3 UNOBSERVABLE (undecodable print, unreadable conf, unwritable output) WHAT IT IS, HONESTLY. A FLAT-FRONT preview: the print is multiplied onto the fabric albedo (ink is subtractive: it can only darken cotton, never brighten it) and the whole front is shaded by a procedural jersey-knit relief (wale and course pitch, relief depth, ambient floor -- all conf rows) under an upper-left light, so the print reads as ink on a knitted surface rather than a flat composite. It is NOT a mesh drape: a body-on-mesh render is the next rung (gt_drape_mesh), declared, not implied. Every number is in knowledge/garment_twin.conf, and the fabric albedo rows are DECLARED until the bench swatch (PT7) measures the real blank -- the conf says so.

dependencies 4 imports · 0 importers

nx_syscalls.nx nx_colorsci_lib.nx nx_img_to_rgb.nx nx_png_write.nx nx_garment_twin.nx

imports: nx_syscalls.nxnx_colorsci_lib.nxnx_img_to_rgb.nxnx_png_write.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main gt_usage gt_w sys_write gt_streq sys_mmap nxa_die sys_write ↻ sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ gt_conf cs_conf_int sys_mmap ↻ sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_munmap sys_close sys_free_file sys_munmap ↻ gt_w ↻ gt_w ↻ nx_img_to_rgb sys_mmap ↻ sys_read_file ↻ nx_img_bytes_to_rgb sys_mmap ↻ nx_jpeg_decode_rgb

structs

none

consts

18const GT_EXIT_OK: i64 = 0
19const GT_EXIT_USAGE: i64 = 2
20const GT_EXIT_UNOBSERVABLE: i64 = 3
21const GT_CONF_DEFAULT: *u8 = "knowledge/garment_twin.conf"
22const GT_CHANNELS: i64 = 3
23const GT_BYTE_MAX: i64 = 255
24const GT_PERMIL: i64 = 1000
25const GT_SLOT: i64 = 8
26const GT_LINE_CAP: i64 = 1024
27const GT_LUMA_R_MILLI: i64 = 2126 // Rec. 709 luma weights, milli-units (the photometric mean used for the stats line)
28const GT_LUMA_G_MILLI: i64 = 7152
29const GT_LUMA_B_MILLI: i64 = 722
30const GT_LUMA_DEN: i64 = 10000

functions

32func gt_w(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
called by 4: gt_wngt_confgt_usagemain calls 1: sys_write
33func gt_wn(v: i64) -> i64
called by 1: main calls 3: gt_wsys_mmapsys_write
46func gt_streq(a: *u8, b: *u8) -> i64 { var i: i64 = 0; while a[i] != (0 as u8) { if a[i] != b[i] { return 0 } i = i + 1 } if b[i] != (0 as u8) { return 0 } return 1 }
called by 1: main
47func gt_conf(path: *u8, key: *u8, missing: *i64) -> i64
called by 1: main calls 2: cs_conf_intgt_w
52func gt_clamp8(v: i64) -> i64 { if v < 0 { return 0 } if v > GT_BYTE_MAX { return GT_BYTE_MAX } return v }
called by 1: gt_print_place
57func gt_shade_table(fq: *i64, wale: i64, course: i64, relief_permil: i64, ambient_permil: i64) -> *i64
86func gt_print_place(canvas: *u8, W: i64, H: i64, print: *u8, pw: i64, ph: i64, fab_r: i64, fab_g: i64, fab_b: i64, shade: *i64, wale: i64, course: i64, bx: i64, by: i64, bw: i64, out: *i64) -> i64
called by 1: main calls 1: gt_clamp8
134func gt_usage() -> i64 { gt_w("usage: nx_garment_twin place <print.img> <out.png> [conf]\n" as *u8); return GT_EXIT_USAGE }
called by 1: main calls 1: gt_w
136func main(argc: i64, argv: *i64) -> i64