开发者

What would be the reverse of CGRectUnion()?

I can combine rect1 with rect2 using CGRectUn开发者_如何学运维ion() and get a combined rect3 fine.

Is it possible to subtract a rect1 from a rect3 (which contains rect1) and get a remaining part of rect?


As Brad Larson said, you can't do this in Quartz, because the CGRect functions work with nothing but rects and their component parts (points, sizes, and single numbers).

If you were programming the Mac, I would suggest using another API named HIShape. It's the modern successor to QuickDraw Regions, and as such, it is capable of non-rectangular shapes. Unfortunately, though HIShape is still available on 64-bit Mac OS X, it is not available on iOS.

If you really need something like this, you will have to write it yourself, including your own HIShape-like not-necessarily-rectangular shape class.


Try CGRectIntersection if I could understand you correctly.


well, it depends... on how rect3 contains rect1... i mean, it may happens that the resulting area is no more a rect... for example, if rect1 is all inside rect3 the remaining area is not a rect, so you couldn't use the CGRect object. You could obtain a rect just in case rect3 and rect1 share completely a side and have it (all of it) in common. So i need to know what kind of objet you wanna obtain by that subtraction... may it be a new image with 2 different areas coloured? or slit the resuting area in more CGrect (upper rect, left, bitton, right...) what are you going to do with the resulting "object"?

luca

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜