Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// @func ds_grid_trim
- /// @arg {grid} grid
- /// @desc Resizes the grid, trimming empty (non-zero) contiguous rows/columns
- // Requires ds_grid_get_bounds
- enum rect{
- x1,
- y1,
- x2,
- y2
- }
- var _grid = argument[0];
- var _dimArr = ds_grid_get_bounds(_grid);
- var _trimmedGridW = _dimArr[rect.x2] - _dimArr[rect.x1] + 1;
- var _trimmedGridH = _dimArr[rect.y2] - _dimArr[rect.y1] + 1;
- var _trimmedGrid = ds_grid_create(_trimmedGridW,_trimmedGridH);
- ds_grid_set_grid_region(_trimmedGrid,_grid,_dimArr[rect.x1],_dimArr[rect.y1],_dimArr[rect.x2],_dimArr[rect.y2],0,0);
- ds_grid_resize(_grid,_trimmedGridW,_trimmedGridH);
- ds_grid_clear(_grid,0);
- ds_grid_copy(_grid,_trimmedGrid);
- ds_grid_destroy(_trimmedGrid);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement