local sel = selection.area(4,5, 40,10) ~ selection.rect(7,8, 60,14); */
| 329 | |
| 330 | /* local sel = selection.area(4,5, 40,10) ~ selection.rect(7,8, 60,14); */ |
| 331 | staticfn int |
| 332 | l_selection_xor(lua_State *L) |
| 333 | { |
| 334 | int x,y; |
| 335 | struct selectionvar *sela = l_selection_check(L, 1); |
| 336 | struct selectionvar *selb = l_selection_check(L, 2); |
| 337 | struct selectionvar *selr = l_selection_push_new(L); |
| 338 | NhRect rect = cg.zeroNhRect; |
| 339 | |
| 340 | rect_bounds(sela->bounds, selb->bounds, &rect); |
| 341 | |
| 342 | for (x = rect.lx; x <= rect.hx; x++) |
| 343 | for (y = rect.ly; y <= rect.hy; y++) { |
| 344 | int val = (selection_getpoint(x, y, sela) |
| 345 | ^ selection_getpoint(x, y, selb)); |
| 346 | |
| 347 | selection_setpoint(x, y, selr, val); |
| 348 | } |
| 349 | /* this may have created a smaller or irregular selection with |
| 350 | * bounds_dirty set to true - update its boundaries */ |
| 351 | selection_recalc_bounds(selr); |
| 352 | |
| 353 | lua_remove(L, 1); |
| 354 | lua_remove(L, 1); |
| 355 | return 1; |
| 356 | } |
| 357 | |
| 358 | /* local sel = selection.area(10,10, 20,20) - selection.area(14,14, 17,17) |
| 359 | * - i.e. points that are in A but not in B */ |
nothing calls this directly
no test coverage detected