techno
techno

Reputation: 6500

Drawing text at an angle on NSImage

I need to allow the user to write text on an NSImage at an angle.The user can specify the angle.

                    let textsize = text.size(withAttributes: textFontAttributes)
                    context.saveGState()
                    context.rotate(by: CGFloat(userangle))                        
                    text.draw(at: counterpoint, withAttributes: textFontAttributes)
                    context.restoreGState()

But this is not producing intended result. The following is what I'm trying to achieve

enter image description here

Upvotes: 0

Views: 98

Answers (1)

Leo Dabus
Leo Dabus

Reputation: 236370

I guess you are trying to pass an angle using degrees but that method requires you to pass the angle in radians.

To convert your angle in degrees to radians you can check this How can I convert from degrees to radians?

Upvotes: 1

Related Questions