function calculateScale(width, height, wantedWidth, wantedHeight) {
  if (wantedWidth !== undefined && wantedHeight !== undefined) {
    return [wantedWidth / width, wantedHeight / height];
  }
  if (wantedWidth !== undefined) {
    return wantedWidth / width;
  }
  if (wantedHeight !== undefined) {
    return wantedHeight / height;
  }
  return 1;
}
@param {number} width The width.
@param {number} height The height.
@param {number|undefined} wantedWidth The wanted width.
@param {number|undefined} wantedHeight The wanted height.
@return {number|Array<number>} The scale.