Why does this CGRectContainsPoint fail?

I guess I don't entirely understand the containsPoint method:

// test
CGRect compareRect = CGRectMake(-39, -62, 39, 62);
CGPoint comparePoint = CGPointMake(3, -27);
if( CGRectContainsPoint(compareRect, comparePoint) ) NSLog(@"works");
else NSLog(@"doesn't work");

When I plot it the point is inside the rectangle. But it returns "doesn't work."


The 3rd and 4th parameter for CGRectMake is width, height. So compareRect is from (-39, -62) to (0, 0) which does not contain (3, -27). It's a common mistake to think that the parameters are (x1, y1, x2, y2), but they are not. Actually they are (x, y, w, h).

Need Your Help

python numpy recarray stacking

python recarray

How can I stack or join numpy recarrays without getting errors like:

Classic database insert problem

mysql concurrency insert

I have a SQL database which i use to store some info and every record has a unique id generated by the database. MY program is written in flash and runs over the web, the program runs fine and it i...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.