Invert GMLscripts.com

ds_grid_delete_row

Deletes from a grid the row at a given row index. The grid is reduced in height by one.

$$\mathbf{G} = \begin{array}{|c|c|c|c|} \hline 00&10&20&30 \\\hline 01&11&21&31 \\\hline \color{#F80}{02}&\color{#F80}{12}&\color{#F80}{22}&\color{#F80}{32} \\\hline 03&13&23&33 \\\hline \end{array} \qquad f(\mathbf{G},2) = \begin{array}{|c|c|c|c|} \hline 00&10&20&30 \\\hline 01&11&21&31 \\\hline 03&13&23&33 \\\hline \end{array}$$

WARNING: Attempting to delete a row from a grid with only one row will generate an error.

ds_grid_delete_row(grid, row)
Deletes from a grid the row at a given row index.
COPY/// @func   ds_grid_delete_row(grid, row)
///
/// @desc   Deletes from a grid the row at a given row
///         index. The grid is reduced in height by one.
///
///         Warning: Attempting to delete a row from a grid
///         with only one row will generate an error.
///
/// @param  {grid}      grid        grid data structure
/// @param  {real}      row         row index
///
/// GMLscripts.com/license

function ds_grid_delete_row(grid, row)
{
    var w = ds_grid_width(grid);
    var h = ds_grid_height(grid);

    ds_grid_set_grid_region(grid, grid, 0, row+1, w-1, h-1, 0, row);
    ds_grid_resize(grid, w, h-1);
}

Contributors: xot

GitHub: View · Commits · Blame · Raw