开发者

Does a given rect intersect a rotated view?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜