Skip to content

2.15 • Offset functions for points

Choose a tag to compare

@KyNorthstar KyNorthstar released this 15 Jan 19:50
· 16 commits to production since this release
cd266c1

For 2D points, you can now shift them around by offsetting them with these functions:

  • .offset(dx:dy:)
  • .offset(by:)
  • +

Which you can use like this:

CGPoint(x: 20, y: 42).offset(dx: 7, dy: -5)                  == CGPoint(x: 27, y: 37)
IntPoint(x: 123, y: 456).offset(by: IntPoint(x: -200, -420)) == IntPoint(x: -77, 36)
UIntPoint.zero + UIntPoint(x: 6, y: 7)                       == UIntPoint(x: 6, y: 7)