Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/aienux/allen/tests/surface.om # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / aienux / allen / tests / surface.om` 309 lines ยท 6638 bytes Raw Blame History 1 note Surface tests: removing clipping, using constant background or bypassing drawing must fail. 2 note The surface draws packed 0x00RRGGBB words into the native frame Nfrm (look-paint.om) with 3 note Lg 0..1 as the native size. A 32 x 32 native frame gives scale 1 and no offset, so the 4 note logical geometry equals the former Canvas tests; 70 x 66 and 3840 x 2160 check the scale. 5 global Csave uint 1024 6 global Cmeta ulong 16 7 const CNIGHT ulong 395282 8 fn test ok bool to void 9 check ok add get Checks 0 1 10 end 11 fn cvframe w ulong h ulong to void 12 note The native size and the night background the look leaves; one sentinel word past it. 13 put Lg 0 long w 14 put Lg 1 long h 15 for i ulong mul w h 16 put Nfrm i uint CNIGHT 17 end 18 put Nfrm mul w h 0 19 end 20 fn cvat x ulong y ulong to ulong 21 ret ulong get Nfrm add mul y 32 x 22 end 23 fn cvkeep to void 24 for i ulong 1024 25 put Csave i get Nfrm i 26 end 27 for i ulong 8 28 put Cmeta i get Cv i 29 put Cmeta add i 8 get Cvs i 30 end 31 end 32 fn cvsame to bool 33 for i ulong 1024 34 if ne get Nfrm i get Csave i 35 ret false 36 end 37 end 38 for i ulong 8 39 if ne get Cv i get Cmeta i 40 ret false 41 end 42 if ne get Cvs i get Cmeta add i 8 43 ret false 44 end 45 end 46 ret true 47 end 48 fn cvink to ulong 49 ink = ulong 0 50 for i ulong 1024 51 if ne ulong get Nfrm i CNIGHT 52 ink = add ink 1 53 end 54 end 55 ret ink 56 end 57 fn cvrefclip to bool 58 ink = ulong 0 59 for y ulong 32 60 for x ulong 32 61 at = add mul y 32 x 62 inside = and ge x 8 lt x 16 63 inside = and inside and ge y 8 lt y 16 64 v = ulong get Nfrm at 65 if inside 66 if ne v ulong get Csave at 67 ret false 68 end 69 if ne v CNIGHT 70 ink = add ink 1 71 end 72 else 73 if ne v CNIGHT 74 ret false 75 end 76 end 77 end 78 end 79 ret gt ink 0 80 end 81 fn cvfrac to bool 82 cvframe 32 32 83 b = cvinit 32 32 84 b = afinit 14 900 85 for i ulong 3 86 put Dtext i 65 87 end 88 if not cvspan 0 3 -1 20 `15528188` 89 ret false 90 end 91 one = get Af 5 92 if ne get Cv 7 mul one 3 93 ret false 94 end 95 cvkeep 96 cvframe 32 32 97 b = cvinit 32 32 98 for i ulong 3 99 x = affloor add long -256 long mul one i 100 if not cvglyph 65 x 20 `15528188` 101 ret false 102 end 103 end 104 for i ulong 1024 105 if ne get Nfrm i get Csave i 106 ret false 107 end 108 end 109 ret true 110 end 111 fn cvfills to void 112 note A logical fill blends from the current pixel, clamps alpha, refuses an oversized rectangle 113 note and stays inside the clip. 114 cvframe 32 32 115 test cvinit 32 32 116 cvfill 1 1 2 2 `15528188` 128 117 test eq cvat 1 1 `7961735` 118 test eq cvat 2 2 `7961735` 119 test eq cvat 0 0 CNIGHT 120 test eq cvat 3 3 CNIGHT 121 test eq cvat 1 3 CNIGHT 122 test eq cvat 3 1 CNIGHT 123 cvfill 1 1 2 2 `15528188` 128 124 test eq cvat 1 1 `11712193` 125 cvfill 1 1 2 2 0 999 126 test eq cvat 2 2 0 127 cvfill 31 0 2 1 `15528188` 255 128 test eq cvat 31 0 CNIGHT 129 test cvclip 8 8 8 8 130 cvfill 0 0 32 32 `15528188` 255 131 test eq cvat 7 7 CNIGHT 132 test eq cvat 8 8 `15528188` 133 test eq cvat 15 15 `15528188` 134 test eq cvat 16 16 CNIGHT 135 end 136 fn cvscale to void 137 note 70 x 66 native pixels hold the 32 x 32 surface at scale 2, centred at (3, 1). 138 cvframe 70 66 139 test cvinit 32 32 140 test eq get Cvs 0 2 141 test eq get Cvs 2 3 142 test eq get Cvs 3 1 143 test eq get Cvs 4 3 144 test eq get Cvs 5 1 145 test eq get Cvs 6 64 146 test eq get Cvs 7 64 147 cvfill 0 0 1 1 `15528188` 255 148 test eq get Nfrm 73 `15528188` 149 test eq get Nfrm 74 `15528188` 150 test eq get Nfrm 143 `15528188` 151 test eq get Nfrm 144 `15528188` 152 test eq ulong get Nfrm 72 CNIGHT 153 test eq ulong get Nfrm 75 CNIGHT 154 test eq ulong get Nfrm 3 CNIGHT 155 test eq ulong get Nfrm 213 CNIGHT 156 test cvfont 10 900 157 test eq get Cvs 1 10 158 cvpixel 2 0 255 0 159 test eq ulong get Nfrm 2 CNIGHT 160 cvpixel 3 1 255 0 161 test eq get Nfrm 73 0 162 put Lg 0 3840 163 put Lg 1 2160 164 test cvinit 768 384 165 test eq get Cv 0 768 166 test eq get Cv 1 384 167 test eq get Cvs 0 5 168 test eq get Cvs 2 0 169 test eq get Cvs 3 120 170 test eq get Cvs 6 3840 171 test eq get Cvs 7 1920 172 end 173 fn main to int 174 test not cvglyph 65 0 0 `15528188` 175 test not cvinit 0 32 176 test not cvinit 32 0 177 test not cvinit 769 32 178 test not cvinit 32 385 179 cvframe 32 32 180 test cvinit 32 32 181 test eq get Cv 0 32 182 test eq get Cv 1 32 183 test eq get Cv 4 32 184 test eq get Cv 5 32 185 test eq get Cvs 0 1 186 test eq get Cvs 2 0 187 test eq get Cvs 3 0 188 test eq get Cvs 6 32 189 test eq get Cvs 7 32 190 test eq cvat 0 0 CNIGHT 191 test eq cvat 31 31 CNIGHT 192 test eq get Nfrm 1024 0 193 test not cvglyph 65 0 0 `15528188` 194 test afinit 20 1000 195 note Exact alpha arithmetic and repeated overlap must use current destination. 196 cvpixel 0 0 0 `15528188` 197 test eq cvat 0 0 CNIGHT 198 cvpixel 0 0 128 `15528188` 199 test eq cvat 0 0 `7961735` 200 cvpixel 0 0 128 `15528188` 201 test eq cvat 0 0 `11712193` 202 cvpixel 0 0 255 `15528188` 203 test eq cvat 0 0 `15528188` 204 cvkeep 205 cvpixel -1 0 255 0 206 cvpixel 0 -1 255 0 207 cvpixel 32 0 255 0 208 cvpixel 0 32 255 0 209 test cvsame 210 test not cvinit `18446744073709551615` 1 211 test cvsame 212 test not cvclip 33 0 0 0 213 test not cvclip 0 33 0 0 214 test not cvclip 0 0 33 1 215 test not cvclip 0 0 1 33 216 test not cvclip 1 1 `18446744073709551615` 1 217 test cvsame 218 test not cvglyph 65 -4097 0 `15528188` 219 test not cvglyph 65 4097 0 `15528188` 220 test not cvglyph 65 0 -4097 `15528188` 221 test not cvglyph 65 0 4097 `15528188` 222 test not cvglyph 65 0 0 `16777216` 223 test cvsame 224 note Independent reference crop of the already rendered glyph. 225 cvframe 32 32 226 test cvinit 32 32 227 test cvglyph 65 4 24 `15528188` 228 test gt get Cv 7 0 229 cvkeep 230 cvframe 32 32 231 test cvinit 32 32 232 test cvclip 8 8 8 8 233 put Nfrm 1024 165 234 test cvglyph 65 4 24 `15528188` 235 test cvrefclip 236 test eq get Nfrm 1024 165 237 note Zero-area and edge clips cannot draw any pixel. 238 cvframe 32 32 239 test cvinit 32 32 240 test cvclip 32 32 0 0 241 cvkeep 242 test cvglyph 65 -8 6 `15528188` 243 put Cmeta 7 get Cv 7 244 test cvsame 245 note A negative origin that intersects the surface must draw without wrapping. 246 test cvclip 0 0 32 32 247 test cvglyph 65 -8 6 `15528188` 248 test gt cvink 0 249 test eq get Nfrm 1024 0 250 note Explicit retained-text span agrees with two separately positioned glyphs. 251 put Dtext 0 65 252 put Dtext 1 65 253 cvframe 32 32 254 test cvinit 32 32 255 put Outb 0 88 256 put Outlen 0 1 257 put Err 0 7 258 put In 8191 99 259 ok = cvspan 0 2 1 24 `15528188` 260 clean = and eq get Outb 0 88 eq get Outlen 0 1 261 clean = and clean eq get Err 0 7 262 test ok 263 test clean 264 test eq get In 8191 99 265 advance = get Cv 7 266 cvkeep 267 cvframe 32 32 268 test cvinit 32 32 269 test cvglyph 65 1 24 `15528188` 270 one = get Cv 7 271 x = add long 1 long div one 256 272 test cvglyph 65 x 24 `15528188` 273 test eq advance mul one 2 274 same = true 275 for i ulong 1024 276 if ne get Nfrm i get Csave i 277 same = false 278 end 279 end 280 test same 281 note Refused spans and extreme offsets preserve pixels and all surface metadata. 282 cvkeep 283 test not cvspan 2305 0 0 0 0 284 test not cvspan 2304 1 0 0 0 285 test not cvspan 1 `18446744073709551615` 0 0 0 286 test not cvspan 0 1 0 0 `18446744073709551615` 287 test not cvspan 0 1 -4097 0 0 288 test cvsame 289 test cvspan 2304 0 0 0 0 290 test eq get Cv 7 0 291 test eq get Dtext 0 65 292 test eq get Dtext 1 65 293 test cvfrac 294 for i ulong 2304 295 put Dtext i 65 296 end 297 cvframe 32 32 298 test cvinit 32 32 299 cvkeep 300 test cvspan 0 2304 4096 0 `15528188` 301 put Cmeta 7 get Cv 7 302 test cvsame 303 cvfills 304 cvscale 305 if ne get Fails 0 0 306 ret 1 307 end 308 ret 0 309 end