Artifact.fromFlatListOfBool constructor

Artifact.fromFlatListOfBool(
  1. List<bool> inputList,
  2. int width
)

Creates an Artifact from a flat list of boolean values.

inputList A flat list of boolean values. width The width of the resulting matrix.

Implementation

factory Artifact.fromFlatListOfBool(
  final List<bool> inputList,
  final int width,
) {
  final rows = inputList.length ~/ width;

  final Artifact artifact = Artifact(width, rows);

  for (int y = 0; y < rows; y++) {
    final List<bool> values = inputList.sublist(y * width, (y + 1) * width);
    for (int x = 0; x < values.length; x++) {
      artifact.cellSet(x, y, values[x]);
    }
  }
  return artifact;
}