padVerticallyArtifactToMatchTheBand method
void
padVerticallyArtifactToMatchTheBand()
Vertically pads artifacts to match the height of the band.
This method ensures all artifacts in the band have the same vertical dimensions by adding empty rows at the top and bottom of each artifact's matrix as needed. It also adjusts the vertical position of each artifact to align with the band's top edge.
The process involves:
- Calculating the required padding for each artifact
- Adding empty rows to the artifact matrices
- Adjusting the vertical position of artifacts to align with the band
Implementation
void padVerticallyArtifactToMatchTheBand() {
int bandTop = rectangleOriginal.top;
int bandBottom = rectangleOriginal.bottom;
for (final Artifact artifact in artifacts) {
// Calculate how many rows to pad at the top
int rowsToPadTop = (artifact.locationFound.y - bandTop).toInt();
// Calculate how many rows to pad at the bottom
int rowsToPadBottom =
(bandBottom - (artifact.locationFound.y + artifact.rows)).toInt();
// If padding is needed, add empty matrix rows at the top and bottom
if (rowsToPadTop > 0 || rowsToPadBottom > 0) {
// Add the empty rows to the artifact matrix
artifact.padTopBottom(
paddingTop: rowsToPadTop,
paddingBottom: rowsToPadBottom,
);
// adjust the location found to be the same as the top of the band
artifact.locationFound = IntOffset(artifact.locationFound.x, bandTop);
}
}
}