code wiki / (root) / nx_arousal_detail_test.nx

nx_arousal_detail_test.nx source

↩ module page · 111 lines · 4517 B

1import "nx_syscalls.nx" 2import "nx_image.nx" 3import "nx_skin_pore_detail.nx" 4import "nx_body_flush.nx" 5 6func paint_rect(rgb: *Image, x0: i64, y0: i64, x1: i64, y1: i64, 7 r: i64, g: i64, b: i64) -> i64 { 8 var y: i64 = y0 9 while y < y1 { 10 var x: i64 = x0 11 while x < x1 { 12 if x >= 0 { if x < rgb.width { if y >= 0 { if y < rgb.height { 13 nx_image_set(rgb, x, y, 0, r) 14 nx_image_set(rgb, x, y, 1, g) 15 nx_image_set(rgb, x, y, 2, b) 16 } } } } 17 x = x + 1 18 } 19 y = y + 1 20 } 21 return 0 22} 23 24func fill_mask(mask: *Image) -> i64 { 25 var y: i64 = 0 26 while y < mask.height { 27 var x: i64 = 0 28 while x < mask.width { nx_image_set(mask, x, y, 0, 255); x = x + 1 } 29 y = y + 1 30 } 31 return 0 32} 33 34func main() -> i64 { 35 let rgb: *Image = nx_image_alloc(120, 120, 3) 36 let mask: *Image = nx_image_alloc(120, 120, 1) 37 fill_mask(mask) 38 39 // ========================================================== 40 // T1: nx_skin_pore_detail — SMOOTH MANNEQUIN (uniform skin). 41 // ========================================================== 42 paint_rect(rgb, 0, 0, 120, 120, 200, 170, 160) 43 let pore_res: *i64 = (sys_mmap(NX_PORE_RES_FIELDS * 8 + 16)) as *i64 44 nx_skin_pore_detail(rgb, mask, pore_res) 45 let v1: i64 = pore_res[NX_PORE_RES_VERDICT] 46 let m1: i64 = pore_res[NX_PORE_RES_MEAN_RES] 47 if v1 != NX_PORE_VERDICT_SMOOTH_MANNEQUIN { return 1 } 48 if m1 > 2 { return 2 } 49 50 // ========================================================== 51 // T2: DETAILED_NATURAL — speckle noise pattern (simulating pores). 52 // ========================================================== 53 paint_rect(rgb, 0, 0, 120, 120, 200, 170, 160) 54 // Sprinkle dark pixels at regular intervals to simulate pores. 55 var py: i64 = 2 56 while py < 118 { 57 var px: i64 = 2 58 while px < 118 { 59 // Every 4th pixel pattern: alternating dark/light to create high-freq texture. 60 if (py + px) - ((py + px) / 4) * 4 == 0 { 61 nx_image_set(rgb, px, py, 0, 130) 62 nx_image_set(rgb, px, py, 1, 100) 63 nx_image_set(rgb, px, py, 2, 90) 64 } 65 px = px + 1 66 } 67 py = py + 1 68 } 69 nx_skin_pore_detail(rgb, mask, pore_res) 70 let v2: i64 = pore_res[NX_PORE_RES_VERDICT] 71 let m2: i64 = pore_res[NX_PORE_RES_MEAN_RES] 72 if m2 < 8 { return 10 } 73 if v2 != NX_PORE_VERDICT_DETAILED_NATURAL { return 11 } 74 75 // ========================================================== 76 // T3: nx_body_flush — NO FLUSH (baseline R = chest R = neck R). 77 // ========================================================== 78 paint_rect(rgb, 0, 0, 120, 120, 200, 170, 160) 79 let pack: *i64 = (sys_mmap(16 * 8 + 16)) as *i64 80 pack[0] = 0; pack[1] = 100; pack[2] = 20; pack[3] = 119 // baseline at bottom 81 pack[4] = 0; pack[5] = 40; pack[6] = 119; pack[7] = 60 // chest 82 pack[8] = 0; pack[9] = 10; pack[10] = 119; pack[11] = 30 // neck 83 pack[12] = 0; pack[13] = 60; pack[14] = 119; pack[15] = 90 // decolletage 84 let flush_res: *i64 = (sys_mmap(NX_FLUSH_RES_FIELDS * 8 + 16)) as *i64 85 nx_body_flush(rgb, mask, pack, flush_res) 86 let fv1: i64 = flush_res[NX_FLUSH_RES_VERDICT] 87 if fv1 != NX_FLUSH_VERDICT_NONE { return 20 } 88 89 // ========================================================== 90 // T4: AROUSAL_FLUSH — chest + neck both elevated by 25 R. 91 // ========================================================== 92 paint_rect(rgb, 0, 0, 120, 120, 200, 170, 160) 93 paint_rect(rgb, 0, 10, 120, 30, 225, 170, 160) // neck R=225 vs baseline 200 → +25 94 paint_rect(rgb, 0, 40, 120, 60, 225, 170, 160) // chest R=225 → +25 95 nx_body_flush(rgb, mask, pack, flush_res) 96 let fv2: i64 = flush_res[NX_FLUSH_RES_VERDICT] 97 let chest_d: i64 = flush_res[NX_FLUSH_RES_CHEST_R] 98 if chest_d < 20 { return 30 } 99 if fv2 != NX_FLUSH_VERDICT_AROUSAL { return 31 } 100 101 // ========================================================== 102 // T5: INTENSE — chest +40 R. 103 // ========================================================== 104 paint_rect(rgb, 0, 0, 120, 120, 200, 170, 160) 105 paint_rect(rgb, 0, 40, 120, 60, 240, 170, 160) // chest R=240 → +40 106 nx_body_flush(rgb, mask, pack, flush_res) 107 let fv3: i64 = flush_res[NX_FLUSH_RES_VERDICT] 108 if fv3 != NX_FLUSH_VERDICT_INTENSE { return 40 } 109 110 return 0 111}