Function LayerData.idxToRow

get the row corresponding to a position in the data or objects array.

Prototype

auto ulong idxToRow(
  ulong idx
) @property;

Example

LayerData layer;
layer.numCols = 3;
layer.numRows = 2;

assert(layer.idxToRow(0) == 0);
assert(layer.idxToRow(1) == 0);
assert(layer.idxToRow(2) == 0);
assert(layer.idxToRow(3) == 1);
assert(layer.idxToRow(4) == 1);
assert(layer.idxToRow(5) == 1);
}

/// get the column corresponding to a position in the data or objects array.
auto idxToCol(size_t idx) { return idx % numCols; 

Authors

rcorre

Copyright

Copyright © 2015, Ryan Roden-Corrent

License

MIT