Author
Travis Kirton


Anchor Point

All geometric manipulations to a view occur about the its’s anchorPoint. You can set the anchor point to something other than the view’s center.

Then, for example, if you rotate the view it will apply the transformation around the anchorPoint rather than it’s visible center.

The anchorPoint is measured in coordinates relative to the view. It’s default value is (0.5, 0.5).

view.anchorPoint = Point()

Example

for i in 0...9 {
    let t = Triangle([Point(), Point(86,50), Point(0, 100)])
    t.anchorPoint = Point(-1.0, 0.5)
    wait(0.25) {
        t.rotation = 2*M_PI * Double(i)/10
    }
    t.center = canvas.center
    canvas.add(t)
}