ds_grid_swap_rows
Exchanges the contents of two entire grid rows.
$$\mathbf{G} = \begin{array}{|c|c|c|c|} \hline \color{#F80}A&\color{#F80}B&\color{#F80}C&\color{#F80}D \\\hline E&F&G&H \\\hline \color{#C8F}I&\color{#C8F}J&\color{#C8F}K&\color{#C8F}L \\\hline M&N&O&P \\\hline \end{array} \qquad f(\mathbf{G},0,2) = \begin{array}{|c|c|c|c|} \hline \color{#C8F}I&\color{#C8F}J&\color{#C8F}K&\color{#C8F}L \\\hline E&F&G&H \\\hline \color{#F80}A&\color{#F80}B&\color{#F80}C&\color{#F80}D \\\hline M&N&O&P \\\hline \end{array}$$
- ds_grid_swap_rows(grid, row1, row2)
- Exchanges the contents of two entire grid rows.
COPY/// @func ds_grid_swap_rows(grid, row1, row2)
///
/// @desc Exchanges the contents of two entire grid rows.
///
/// @param {grid} grid grid data structure
/// @param {real} row1 1st row of the exchange
/// @param {real} row2 2nd row of the exchange
///
/// GMLscripts.com/license
function ds_grid_swap_rows(grid, row1, row2)
{
for (var i=0; i<ds_grid_width(grid); i++) {
var temp = ds_grid_get(grid, i, row1);
ds_grid_set(grid, i, row1, ds_grid_get(grid, i, row2));
ds_grid_set(grid, i, row2, temp);
}
}
Contributors: Quimp
GitHub: View · Commits · Blame · Raw