Band.splitArtifactIntoBand constructor
Creates a Band from an artifact region matrix.
This factory method analyzes a region matrix to find sub-artifacts, positions them correctly using the provided offset, and creates a new Band containing these artifacts.
Parameters:
regionMatrix: The artifact matrix representing a region to analyze.
offset: The position offset to apply to found artifacts.
Returns: A new Band containing the properly positioned and processed artifacts.
Implementation
factory Band.splitArtifactIntoBand({
required final Artifact regionMatrix,
required final IntOffset offset,
}) {
//
// Find the Matrices in the Region
//
List<Artifact> artifactsFound = regionMatrix.findSubArtifacts();
//
// IntOffset their locations found
//
offsetArtifacts(artifactsFound, offset.x.toInt(), offset.y.toInt());
//
// Band
//
final Band newBand = Band();
// sort horizontally
artifactsFound.sort(
(a, b) => a.locationFound.x.compareTo(b.locationFound.x),
);
for (final Artifact artifact in artifactsFound) {
if (artifact.discardableContent() == false) {
newBand.addArtifact(artifact);
}
}
// All artifact will have the same grid height
newBand.padVerticallyArtifactToMatchTheBand();
// Clean up inner Matrix overlap for example the letter X may have one of the lines not touching the others like so `/,
newBand.mergeArtifactsBasedOnVerticalAlignment();
newBand.clearStats();
return newBand;
}