Move all rectangle's points simultaneously
<p>I'm writing a code for app building rectangles. I can separately move rectangles' points with left mouse button (<kbd>LMB</kbd>).</p>

<p><strong>How could I move all four points of a rectangle simultaneously</strong>? </p>

<p>The principle of operation: if I drag 1 point with a <kbd>LMB</kbd>, the other 3 will follow it at the same time with the same offset.</p>

<p><a href="https://i.stack.imgur.com/iKCXb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iKCXb.png" alt="enter image description here"></a></p>

<p>This is how elements were constructed:</p>

<pre><code>enum RectPoint {

    case point1(point: CGPoint)
    case point2(point: CGPoint)
    case point3(point: CGPoint)
    case point4(point: CGPoint)

    func pointCoord() -&gt; [CGPoint] {    
        switch self {  
            case .point1(let point): return [point]
            case .point2(let point): return [point]
            case .point3(let point): return [point]
            case .point4(let point): return [point]
        }
    }
    ..........................
}

class SpecialView: NSView {

    var array: [RectPoint] = [] 
    private var trackVertex: RectPoint?
    private var trackVertexIndex: Int?
    private var trackElementIndex: Int?

    ..........................

    private func updateDragging(point: CGPoint) {
        guard let trackVertex = self.trackVertex,
              let trackVertexIndex = self.trackVertexIndex,
              let trackElementIndex = self.trackElementIndex   
        else { 
            return 
        }

        let newVertex = trackVertex.debugReleaseChecking(point, 
                                                atElementIndex: trackElementIndex)

        array[trackVertexIndex] = newVertex     
        self.needsDisplay = true
    }
}
</code></pre>

<p>Here's a method for dragging with LMB:</p>

<pre><code>func mouseDragged(event: NSEvent) {

   var point = self.convertPoint(event.locationInWindow, fromView: nil)
   updateDragging(point) 
}
</code></pre>

<p><em>I need a code (or pseudo code) that allows me to drag all four points of any rectangle at a time.</em></p>