getMatrix method

Artifact getMatrix(
  1. String character,
  2. int matricesIndex
)

Retrieves a specific Artifact for a given character.

This method fetches a character definition and returns the matrix at the specified index. If the character definition doesn't exist or the index is out of bounds, an empty matrix is returned.

Parameters:

  • character: A String representing the character for which to retrieve the matrix. This should be a single character, typically.
  • matricesIndex: An int specifying the index of the desired matrix within the character's definition. Different indices may represent variations or different representations of the character.

Returns:

  • A Artifact object representing the character at the specified index.
  • Returns an empty Artifact if:
    • No definition is found for the character.
    • The matricesIndex is negative.
    • The matricesIndex is out of bounds for the character's matrices.

Implementation

Artifact getMatrix(final String character, final int matricesIndex) {
  final CharacterDefinition? definition = getDefinition(character);
  if (definition == null ||
      matricesIndex < 0 ||
      matricesIndex >= definition.matrices.length) {
    return Artifact(0, 0);
  }
  return definition.matrices[matricesIndex];
}