Invert GMLscripts.com

ds_grid_delete_column

Deletes from a grid the column at a given column index. The grid is reduced in width by one.

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

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

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

function ds_grid_delete_column(grid, col)
{
    var w = ds_grid_width(grid);
    var h = ds_grid_height(grid);

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

Contributors: xot

GitHub: View · Commits · Blame · Raw