copyArtifactGrid static method

void copyArtifactGrid(
  1. Artifact source,
  2. Artifact target,
  3. int offsetX,
  4. int offsetY,
)

Copies the contents of a source Artifact into a target Artifact, with an optional offset.

This method copies the values from the source Artifact into the target Artifact, starting at the specified offset coordinates. If the source Artifact extends beyond the bounds of the target Artifact, only the portion that fits within the target Artifact will be copied.

Parameters:

  • source: The Artifact to copy from.
  • target: The Artifact to copy into.
  • offsetX: The horizontal offset to apply when copying the source into the target.
  • offsetY: The vertical offset to apply when copying the source into the target.

Implementation

static void copyArtifactGrid(
  final Artifact source,
  final Artifact target,
  final int offsetX,
  final int offsetY,
) {
  for (int y = 0; y < source.rows; y++) {
    for (int x = 0; x < source.cols; x++) {
      if (y + offsetY < target.rows && x + offsetX < target.cols) {
        if (source.cellGet(x, y)) {
          target.cellSet(x + offsetX, y + offsetY, true);
        }
      }
    }
  }
}