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 artifact. It copies the grid data and the rectangle properties from the input artifact.

Parameters:

  • value: The source Artifact instance to copy from.

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

Note: This method creates a deep copy of the grid data.

Example:

Artifact original = Artifact(/* ... */);
Artifact copy = Artifact.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;
}