def intersect(other)
      # direct comparison is dirtier, yet significantly faster than
      # something like [@x0, other.x0].max
      ix0 = @x0 > other.x0 ? @x0 : other.x0
      ix1 = @x1 < other.x1 ? @x1 : other.x1
      iy0 = @y0 > other.y0 ? @y0 : other.y0
      iy1 = @y1 < other.y1 ? @y1 : other.y1

      if ix0 > ix1 || iy0 > iy1
        nil # rectangles are not intersected, in fact
      else
        Rect.new(ix0, iy0, ix1, iy1)
      end
    end
def intersect(other)
      # direct comparison is dirtier, yet significantly faster than
      # something like [@x0, other.x0].max
      ix0 = @x0 > other.x0 ? @x0 : other.x0
      ix1 = @x1 < other.x1 ? @x1 : other.x1
      iy0 = @y0 > other.y0 ? @y0 : other.y0
      iy1 = @y1 < other.y1 ? @y1 : other.y1

      if ix0 > ix1 || iy0 > iy1
        nil # rectangles are not intersected, in fact
      else
        Rect.new(ix0, iy0, ix1, iy1)
      end
    end
rubocop:enable Metrics/PerceivedComplexity,Metrics/CyclomaticComplexity,Metrics/AbcSize