Author
Travis Kirton


Center & Origin

The easiest way to position objects is by setting their origin or center properties.

view.center = Point()
shape.origin = Point()

In C4, all visible objects are Views.

Example

let f = Rect(0, 0, 200, 200)

let r = Rectangle(frame: f)
canvas.add(r)

let e = Ellipse(frame: f)
e.fillColor = C4Pink
canvas.add(e)

let t = Triangle([Point(), Point(173,100), Point(0, 200)])
t.fillColor = C4Grey
canvas.add(t)

r.center = canvas.center
e.center = r.center
t.origin = e.center