splitChunk method

List<Artifact> splitChunk(
  1. Artifact artifactToSplit
)

Splits an artifact into multiple artifacts based on detected valleys.

This method analyzes the given artifact to find natural splitting points (valleys in the pixel density) and divides it into multiple artifacts.

artifactToSplit The artifact to be split into multiple components. Returns a list of new artifacts created from the split.

Implementation

List<Artifact> splitChunk(Artifact artifactToSplit) {
  // Get columns where to split the artifact
  List<int> splitColumns = artifactValleysOffsets(artifactToSplit);

  // If no split columns found, return empty list
  if (splitColumns.isEmpty) {
    return [];
  }

  List<Artifact> artifactsFromColumns = splitArtifactByColumns(
    artifactToSplit,
    splitColumns,
  );

  return artifactsFromColumns;
}