Invert GMLscripts.com

ds_grid_swap_columns

Exchanges the contents of two entire grid columns.

$$\mathbf{G} = \begin{array}{|c|c|c|c|} \hline \color{#F80}A&B&\color{#C8F}C&D \\\hline \color{#F80}E&F&\color{#C8F}G&H \\\hline \color{#F80}I&J&\color{#C8F}K&L \\\hline \color{#F80}M&N&\color{#C8F}O&P \\\hline \end{array} \qquad f(\mathbf{G},0,2) = \begin{array}{|c|c|c|c|} \hline \color{#C8F}C&B&\color{#F80}A&D \\\hline \color{#C8F}G&F&\color{#F80}E&H \\\hline \color{#C8F}K&J&\color{#F80}I&L \\\hline \color{#C8F}O&N&\color{#F80}M&P \\\hline \end{array}$$

ds_grid_swap_columns(grid, col1, col2)
Exchanges the contents of two entire grid columns.
COPY/// @func   ds_grid_swap_columns(grid, col1, col2)
///
/// @desc   Exchanges the contents of two entire grid columns.
///
/// @param  {grid}      grid        grid data structure
/// @param  {real}      col1        1st column of the exchange
/// @param  {real}      col2        2nd column of the exchange
///
/// GMLscripts.com/license

function ds_grid_swap_columns(grid, col1, col2)
{
    for (var i=0; i<ds_grid_height(grid); i++) {
        var temp = ds_grid_get(grid, col1, i);
        ds_grid_set(grid, col1, i, ds_grid_get(grid, col2, i));
        ds_grid_set(grid, col2, i, temp);
    }
}

Contributors: Quimp

GitHub: View · Commits · Blame · Raw