Artifact.fromMatrix constructor

Artifact.fromMatrix(
  1. Artifact value
)

Creates a new Artifact instance from an existing Artifact.

This factory method creates a new Artifact instance based on the provided value matrix. It copies the grid data and the rectangle properties from the input matrix.

Parameters:

  • value: The source Artifact instance to copy from.

Returns: A new Artifact instance with the same grid data and rectangle as the input matrix.

Note: This method creates a shallow copy of the grid data. If deep copying of the data is required, consider implementing a separate deep copy method.

Example:

Matrix original = Matrix(/* ... */);
Matrix copy = Matrix.fromMatrix(original);

Implementation

factory Artifact.fromMatrix(final Artifact value) {
  // Create a new Artifact instance with the same dimensions as the source.
  final Artifact artifact = Artifact(value.cols, value.rows);
  // Deep copy the matrix data.
  artifact._matrix = Uint8List.fromList(value._matrix);
  // Copy other relevant properties.
  artifact.locationFound = value.locationFound;
  artifact.locationAdjusted = value.locationAdjusted;
  artifact.matchingCharacter = value.matchingCharacter;
  artifact.matchingScore = value.matchingScore;
  artifact.needsInspection = value.needsInspection;
  artifact.wasPartOfSplit = value.wasPartOfSplit;
  artifact.font = value.font;
  return artifact;
}