Transforming Rects?!?!?!

whitesaint

cocoa love
Okay i know this is possible. But the main question is how to do it. Is it possible to transform a rect? I have found methods to transform points and sizes, but nothing with Rects. If anyone can give me a reference or any help at all with transforming rects, i think many developers would be thankful. Many thanks.\

-whitesaint
 
What's confusing me is how you think a rect would be a point and not a rectangle ;)

All you do is change the size and the origin of the rect. So if you want to the rect's size to grow by a factor of 2, then you do

Code:
rect.size.height = rect.size.height*2
rect.size.width = rect.size.width*2

To translate it, just translate the origin (rect.origin.x and rect.origin.y).

If you want to rotate it and such, I think you use NSAffineTransform.

HTH,
F-bacher
 
Originally posted by Ghoser777
What's confusing me is how you think a rect would be a point and not a rectangle ;)
HTH,
F-bacher

Because in my code i use something with .rect to perform a point!:eek:
 
That's a strange convention. When you say in "your code," does that mean it's a feature of the language you use, the api you use, the platform you develop for, or your personal preference?

F-bacher
 
Back
Top