code wiki / (root) / nx_areola_pigment_test.nx

nx_areola_pigment_test.nx source

↩ module page · 73 lines · 2781 B

1import "nx_syscalls.nx" 2import "nx_image.nx" 3import "nx_areola_pigment.nx" 4 5func paint_areola(rgb: *Image, mask: *Image, r: i64, g: i64, b: i64) -> i64 { 6 let w: i64 = rgb.width 7 let h: i64 = rgb.height 8 var y: i64 = 0 9 while y < h { 10 var x: i64 = 0 11 while x < w { 12 // Areola disk at center, radius ~ 8. 13 let dx: i64 = x - w / 2 14 let dy: i64 = y - h / 2 15 let d2: i64 = dx * dx + dy * dy 16 if d2 <= 64 { 17 nx_image_set(mask, x, y, 0, 255) 18 nx_image_set(rgb, x, y, 0, r) 19 nx_image_set(rgb, x, y, 1, g) 20 nx_image_set(rgb, x, y, 2, b) 21 } else { 22 nx_image_set(mask, x, y, 0, 0) 23 } 24 x = x + 1 25 } 26 y = y + 1 27 } 28 return 0 29} 30 31func main() -> i64 { 32 let rgb: *Image = nx_image_alloc(40, 40, 3) 33 let mask: *Image = nx_image_alloc(40, 40, 1) 34 let result: *i64 = (sys_mmap(NX_AREOLA_RES_FIELDS * 8 + 16)) as *i64 35 36 // T1: Image #46 scenario — DARK BROWN areola painted onto NULLIPAROUS_YOUNG body. 37 // R=90, G=55, B=50 -> max=90, pigment=255-90=165, warmth=35. 38 // Expected for young nulliparous: pigment 60..130 -> 165 is TOO_DARK. 39 paint_areola(rgb, mask, 90, 55, 50) 40 nx_areola_pigment(rgb, mask, NX_REPRO_NULLIPAROUS_YOUNG, result) 41 let v1: i64 = result[NX_AREOLA_RES_VERDICT] 42 let pig1: i64 = result[NX_AREOLA_RES_PIGMENT] 43 if v1 != NX_AREOLA_VERDICT_TOO_DARK { return 1 } 44 if pig1 < 150 { return 2 } 45 if pig1 > 180 { return 3 } 46 47 // T2: Light pink areola — appropriate for young nulliparous. 48 // R=210, G=170, B=170 -> max=210, pigment=45, warmth=40. 49 // pigment 45 is BELOW range 60..130 -> TOO_LIGHT. 50 paint_areola(rgb, mask, 210, 170, 170) 51 nx_areola_pigment(rgb, mask, NX_REPRO_NULLIPAROUS_YOUNG, result) 52 let v2: i64 = result[NX_AREOLA_RES_VERDICT] 53 // T2 is intentionally edge — outside range. Don't enforce exact verdict, 54 // just confirm pigment math is right. 55 let pig2: i64 = result[NX_AREOLA_RES_PIGMENT] 56 if pig2 < 40 { return 10 } 57 if pig2 > 50 { return 11 } 58 59 // T3: Pink-tan in canonical range — pigment ~100, warmth ~50. 60 // R=180, G=130, B=120 -> max=180, pigment=75, warmth=50. 61 paint_areola(rgb, mask, 180, 130, 120) 62 nx_areola_pigment(rgb, mask, NX_REPRO_NULLIPAROUS_YOUNG, result) 63 let v3: i64 = result[NX_AREOLA_RES_VERDICT] 64 if v3 != NX_AREOLA_VERDICT_MATCH { return 20 } 65 66 // T4: Same dark areola against PREGNANT state — should now MATCH. 67 paint_areola(rgb, mask, 90, 55, 50) 68 nx_areola_pigment(rgb, mask, NX_REPRO_PREGNANT, result) 69 let v4: i64 = result[NX_AREOLA_RES_VERDICT] 70 if v4 != NX_AREOLA_VERDICT_MATCH { return 30 } 71 72 return 0 73}