l_selection_grow(L)
lua_State *L;
{
+ int argc = lua_gettop(L);
const char *const growdirs[] = { "all", "random", "north", "west", "east", "south", NULL };
const int growdirs2i[] = { W_ANY, -1, W_NORTH, W_WEST, W_EAST, W_SOUTH, 0 };
struct selectionvar *sel = l_selection_check(L, 1);
int dir = growdirs2i[luaL_checkoption(L, 2, "all", growdirs)];
+
+ if (argc == 2)
+ lua_pop(L, 1); /* get rid of growdir */
+
+ (void) l_selection_clone(L);
+ sel = l_selection_check(L, 1);
selection_do_grow(sel, dir);
lua_settop(L, 1);
return 1;
end
end -- test_sel_randline
+function test_sel_grow()
+ local __func__ = "test_sel_grow";
+ local sela = selection.new();
+
+ sela:set(5,5);
+
+ local sela_clone = sela:clone();
+
+ local selb = sela:grow();
+ sel_are_equal(sela, sela_clone, __func__);
+ sel_has_n_points(selb, 9, __func__);
+ for x = 4,6 do
+ for y = 4,6 do
+ sel_pt_ne(selb, x,y, 1, __func__);
+ end
+ end
+
+ local selc = sela:grow("north");
+ sel_has_n_points(selc, 2, __func__);
+ sel_pt_ne(selc, 5,5, 1, __func__);
+ sel_pt_ne(selc, 5,4, 1, __func__);
+
+ local seld = selc:grow("east");
+ sel_has_n_points(seld, 4, __func__);
+ sel_pt_ne(seld, 5,5, 1, __func__);
+ sel_pt_ne(seld, 5,4, 1, __func__);
+ sel_pt_ne(seld, 6,5, 1, __func__);
+ sel_pt_ne(seld, 6,4, 1, __func__);
+end -- test_sel_grow
+
test_selection_params();
test_sel_negate();
test_sel_logical_and();
test_sel_rect();
test_sel_fillrect();
test_sel_randline();
+test_sel_grow();