code wiki / _hdl_build / nx_uiq_color.nx
nx_uiq_color.nx
buildroot/runtime/_hdl_build/nx_uiq_color.nx
about
nx_uiq_color.nx -- SOVEREIGN UI-QUALITY color engine (no main).
The ONE WCAG 2.x relative-luminance + contrast-ratio implementation for the whole nx_uiq_* family,
PLUS a CSS color parser (#rgb/#rrggbb/rgb()/named) and a custom-property color-token scanner, so the
family computes contrast on the REAL colors extracted from a page instead of one hardcoded token pair.
The math is reused verbatim from nx_contrast (KAT'd to the WCAG reference black/white=21.00,
#767676/white=4.54). CONSOLIDATION SEED: nx_contrast + nx_ui_contrast + nx_brand_guard migrate onto
this on next touch (D001 migrate-on-touch), collapsing 3 duplicate luminance kernels -> 1.
license_tier: ORIGINAL genealogy: w3.org/TR/WCAG21 relative-luminance + contrast-ratio (verbatim)
dependencies 6 imports · 5 importers
imports: nx_syscalls.nxnx_tier.nxnx_f64.nxnx_f64_div.nxnx_f64_cvt.nx_pe_f64pow.nx
imported by: nx_contrast.nxnx_uiq_console_lib.nxnx_uiq_contrast.nxnx_uiq_contrast_gate.nxnx_uiq_perf.nx
structs
| none |
consts
| 15 | const K_MAGIC_1292: i64 = 1292 |
| 16 | const K_MAGIC_1055: i64 = 1055 |
| 17 | const K_MAGIC_2126: i64 = 2126 |
| 18 | const K_MAGIC_10000: i64 = 10000 |
| 19 | const K_MAGIC_7152: i64 = 7152 |
| 20 | const K_MAGIC_1000000: i64 = 1000000 |
| 21 | const K_MAGIC_2100: i64 = 2100 |
| 22 | const K_MAGIC_767676: i64 = 767676 |
| 23 | const K_MAGIC_2126729: i64 = 2126729 |
| 24 | const K_MAGIC_10000000: i64 = 10000000 |
| 25 | const K_MAGIC_7151522: i64 = 7151522 |
| 26 | const K_MAGIC_721750: i64 = 721750 |
| 27 | const K_MAGIC_22000: i64 = 22000 |
| 28 | const K_MAGIC_1414: i64 = 1414 |
| 29 | const K_MAGIC_100000: i64 = 100000 |
functions
| 32 | func uiq_w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 33 | func uiq_pn(v: i64) -> i64 |
| 44 | func uiq_pratio(r100: i64) -> i64 |
| 50 | func uiq_wslice(base: *u8, off: i64, len: i64) -> i64 { sys_write(1, ((base as i64)+off) as *u8, len); return 0 } |
| 53 | func uiq_f64c(num: i64, den: i64) -> i64 { return nx_f64_div(nx_i64_to_f64(num), nx_i64_to_f64(den)) } called by 6: uiq_srgb_linuiq_lumuiq_ratio100uiq_apca_expuiq_apca_yuiq_apca_lc10 calls 2: nx_f64_divnx_i64_to_f64 |
| 54 | func uiq_hxn(c: i64) -> i64 |
| 61 | func uiq_srgb_lin(c: i64) -> i64 |
| 68 | func uiq_lum(r: i64, g: i64, b: i64) -> i64 |
| 75 | func uiq_ratio100(fr: i64, fg: i64, fb: i64, br: i64, bg: i64, bb: i64) -> i64 called by 4: run_katmainuiq_audit_tableuiq_selftest calls 7: uiq_lumnx_f64_to_i64nx_f64_mulnx_i64_to_f64uiq_f64cnx_f64_div+1 |
| 89 | func uiq_clip(v: i64) -> i64 { if v<0 { return 0 } if v>255 { return 255 } return v } called by 1: uiq_three_ints |
| 90 | func uiq_hex2(base: *u8, off: i64) -> i64 { return uiq_hxn(base[off] as i64)*16 + uiq_hxn(base[off+1] as i64) } |
| 91 | func uiq_hex1(base: *u8, off: i64) -> i64 { let h: i64=uiq_hxn(base[off] as i64); return h*16+h } |
| 93 | func uiq_three_ints(base: *u8, off: i64, len: i64, out: *i64) -> i64 |
| 106 | func uiq_word_eq(base: *u8, off: i64, len: i64, lit: *u8) -> i64 |
| 112 | func uiq_parse_color(base: *u8, off: i64, len: i64, out: *i64) -> i64 |
| 134 | func uiq_scan_tokens(buf: *u8, n: i64, toff: *i64, tlen: *i64, trgb: *i64, cap: i64) -> i64 |
| 169 | func uiq_name_eq(buf: *u8, off: i64, len: i64, lit: *u8) -> i64 called by 1: uiq_is_text |
| 175 | func uiq_name_has(buf: *u8, off: i64, len: i64, lit: *u8) -> i64 |
| 188 | func uiq_is_text(buf: *u8, off: i64, len: i64) -> i64 |
| 204 | func uiq_is_surface(buf: *u8, off: i64, len: i64) -> i64 |
| 215 | func uiq_find(buf: *u8, n: i64, pat: *u8) -> i64 called by 1: uiq_audit_buf |
| 227 | func uiq_names_equal(buf: *u8, o1: i64, l1: i64, o2: i64, l2: i64) -> i64 called by 1: uiq_audit_buf |
| 236 | func uiq_audit_table(buf: *u8, uoff: *i64, ulen: *i64, rgb: *i64, un: i64, flags: i64) -> i64 called by 1: uiq_audit_buf calls 7: uiq_wuiq_is_textuiq_is_surfaceuiq_ratio100uiq_wsliceuiq_pratio+1 |
| 277 | func uiq_audit_buf(buf: *u8, n: i64, emit: i64) -> i64 called by 3: uiq_selftestmainmain calls 7: sys_mmapuiq_scan_tokensuiq_finduiq_names_equaluiq_wuiq_pn+1 |
| 334 | func uiq_selftest() -> i64 |
| 372 | func uiq_apca_exp(c: i64) -> i64 { return nx_f64_pow(uiq_f64c(c, 255), uiq_f64c(24, 10)) } |
| 373 | func uiq_apca_y(r: i64, g: i64, b: i64) -> i64 called by 1: uiq_apca_lc10 calls 8: nx_f64_muluiq_f64cuiq_apca_expnx_f64_addnx_f64_to_i64nx_i64_to_f64+2 |
| 386 | func uiq_apca_lc10(fr: i64, fg: i64, fb: i64, br: i64, bg: i64, bb: i64) -> i64 called by 2: run_katmain calls 8: uiq_apca_ynx_f64_to_i64nx_f64_mulnx_i64_to_f64nx_f64_subnx_f64_pow+2 |