开发者

Does a given rect intersect a rotated view?

开发者 https://www.devze.com 2023-02-04 23:34 出处:网络
I have an NSView that is rotated using -setFrameRotation. (This is necessary because the view responds to mouse events, and you don\'t get correct behavior if you merely draw the view with a rotated N

I have an NSView that is rotated using -setFrameRotation. (This is necessary because the view responds to mouse events, and you don't get correct behavior if you merely draw the view with a rotated NSAffineTransform.)

Given a rect in the rotated view's superview coordinates, how can I determine what portion of the rect intersects the rotated view's frame?

Use case: the Cocoa text system proposes to draw text in a line fragment rectangle. I need to determine how much of that rectangle may开发者_如何转开发 be filled with text without overlapping the rotated view.


Take the point, use an affine transform to rotate into the coordinate system of the bounds of the rect and then rect-test that.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号