Returns true if the given pixel coordinates is within the dimensions of the image.
bool isBoundsSafe(num x, num y) => x >= 0 && y >= 0 && x < width && y < height;