I want to show my object, after drawing inner components, rolled to an angle of 45 degrees. How can I achieve this easily?
The object is drawn with a sub-class of a NSView. It incorporates multiple NSBezierPath and fill, to include arcs etc. Then the same object is used a few times at different rotated positions - not animated!
I use the NSView.rotate(byDegrees:) method, but it only seems to work for factors of 90 degrees - other angles seem to scale and omit curves (strange results).
You probably don't need code, but here's the object:
override func draw(_ dirtyRect: NSRect) {
super.draw(dirtyRect)
wantsLayer = true
layer?.masksToBounds = false
let context = NSGraphicsContext.current!.cgContext
let path = NSBezierPath(ovalIn: dirtyRect)
NSColor.red.setFill()
path.fill()
}
then:
let object = MyObject(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
view.addSubView(object)
object.rotate(byDegrees: 23)
I want see many MyObjects, each turned a different amount.
How can I do that easily?