1

I've been having a little success with NSAffineTransform but have come across AffineTransform which is presumably more Swifty. However it doesn't have a concat method, so how do you use it? I'm aiming to draw the same little BezierPath rotated several times round the centre.

Sorry if it's obvious; I guess others might find this useful.

AlexT
  • 596
  • 7
  • 15

1 Answers1

0

Here's how I see it. If you're drawing with an NSBezierPath you apply it to the path with myPath.transform(using: tr), e.g.:

  let tr1 = AffineTransform(translationByX: 20, byY: 20)
  bez = NSBezierPath()
  // add some elements to the path here
  bez.transform(using: tr1)
  bez.stroke()

As I see it, the transform affects all the elements already in the path, but not any elements subsequently added. Transforms are cumulative, in that re-applying a transform, or applying another will affect all the elements so far entered.

You can also use the AffineTransform's own methods to transform individual points or sizes.

AlexT
  • 596
  • 7
  • 15