local sel = selection.area(10,10, 20,20) - selection.area(14,14, 17,17) * - i.e. points that are in A but not in B */
| 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 */ |
| 360 | staticfn int |
| 361 | l_selection_sub(lua_State *L) |
| 362 | { |
| 363 | int x,y; |
| 364 | struct selectionvar *sela = l_selection_check(L, 1); |
| 365 | struct selectionvar *selb = l_selection_check(L, 2); |
| 366 | struct selectionvar *selr = l_selection_push_new(L); |
| 367 | NhRect rect = cg.zeroNhRect; |
| 368 | |
| 369 | rect_bounds(sela->bounds, selb->bounds, &rect); |
| 370 | |
| 371 | for (x = rect.lx; x <= rect.hx; x++) |
| 372 | for (y = rect.ly; y <= rect.hy; y++) { |
| 373 | coordxy a_pt = selection_getpoint(x, y, sela); |
| 374 | coordxy b_pt = selection_getpoint(x, y, selb); |
| 375 | int val = (a_pt ^ b_pt) & a_pt; |
| 376 | selection_setpoint(x, y, selr, val); |
| 377 | } |
| 378 | /* this may have created a smaller or irregular selection with |
| 379 | * bounds_dirty set to true - update its boundaries */ |
| 380 | selection_recalc_bounds(selr); |
| 381 | |
| 382 | lua_remove(L, 1); |
| 383 | lua_remove(L, 1); |
| 384 | return 1; |
| 385 | } |
| 386 | |
| 387 | /* local s = selection.percentage(sel, 50); */ |
| 388 | staticfn int |
nothing calls this directly
no test coverage detected