const x =
    dx < 0
      ? 0
      : dx + position.size > position.canvas.width
        ? position.canvas.width - position.size