nx_canon_proportions_test.nx source
↩ module page · 39 lines · 1582 B
1import "nx_syscalls.nx"
2import "nx_phi.nx"
3import "nx_canon_proportions.nx"
4
5func main() -> i64 {
6 let canon: *i64 = (sys_mmap(NX_CANON_ENTRY_COUNT * NX_CANON_FIELDS * 8 + 16)) as *i64
7 nx_canon_build(canon)
8
9 // T1: face_height : eye_width = 7
10 let idx0: i64 = nx_canon_find(canon, NX_AXIS_FACE_HEIGHT, NX_AXIS_EYE_WIDTH)
11 if idx0 != 0 { return 1 }
12 let t0: i64 = nx_canon_get(canon, idx0, NX_CANON_FIELD_TARGET_Q10)
13 if t0 != NX_R_HEAD_TO_EYE { return 2 }
14
15 // T2: bust : waist = phi (entry 10)
16 let idx_phi: i64 = nx_canon_find(canon, NX_AXIS_BUST_WIDTH, NX_AXIS_WAIST_WIDTH)
17 let t_phi: i64 = nx_canon_get(canon, idx_phi, NX_CANON_FIELD_TARGET_Q10)
18 if t_phi != NX_PHI_Q10 { return 10 }
19 let f_phi: i64 = nx_canon_get(canon, idx_phi, NX_CANON_FIELD_FAMILY)
20 if f_phi != NX_FAMILY_PHI { return 11 }
21
22 // T3: total_height : navel = phi (Vitruvian)
23 let idx_vit: i64 = nx_canon_find(canon, NX_AXIS_TOTAL_HEIGHT, NX_AXIS_NAVEL_HEIGHT)
24 let t_vit: i64 = nx_canon_get(canon, idx_vit, NX_CANON_FIELD_TARGET_Q10)
25 if t_vit != NX_PHI_Q10 { return 20 }
26 let f_vit: i64 = nx_canon_get(canon, idx_vit, NX_CANON_FIELD_FAMILY)
27 if f_vit != NX_FAMILY_VITRUVIAN { return 21 }
28
29 // T4: armspan = height
30 let idx_arm: i64 = nx_canon_find(canon, NX_AXIS_ARM_SPAN, NX_AXIS_TOTAL_HEIGHT)
31 let t_arm: i64 = nx_canon_get(canon, idx_arm, NX_CANON_FIELD_TARGET_Q10)
32 if t_arm != NX_Q10 { return 30 }
33
34 // T5: missing entry returns -1
35 let miss: i64 = nx_canon_find(canon, 99, 99)
36 if miss != -1 { return 40 }
37
38 return 0
39}