discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSBezierPath hit-detection problem


From: swinehart
Subject: NSBezierPath hit-detection problem
Date: Wed, 7 Mar 2001 16:37:13 -0500 (EST)

I've been getting some unexpected behavior from NSBezierPath and I'm
unsure whether it's my expectations that are flawed or that there is a
problem with the class. I've been trying to do hit detection, but it
seems that there is a 1-point border within a given path that is still
scored as being _outside_ of the path.

For example, the following code creates the output listed
below. Shouldn't all but the first and last points be scored as hits? 


Code:
  path = [NSBezierPath bezierPathWithRect:NSMakeRect(0,0,2,2)];
  for (i=-1;i<12;i++){
    pt = NSMakePoint(i*0.2, i*0.2);
    if ([path containsPoint:pt])
      NSLog(@"address@hidden",NSStringFromPoint(pt));
    else 
      NSLog(@"address@hidden",NSStringFromPoint(pt));
  }


Output:
Mar 07 16:35:31 ObjcTest[2354] {x=-0.2; y=-0.2} Outside
Mar 07 16:35:31 ObjcTest[2354] {x=0; y=0}       Outside
Mar 07 16:35:31 ObjcTest[2354] {x=0.2; y=0.2}   Outside
Mar 07 16:35:31 ObjcTest[2354] {x=0.4; y=0.4}   Outside
Mar 07 16:35:31 ObjcTest[2354] {x=0.6; y=0.6}   Outside
Mar 07 16:35:31 ObjcTest[2354] {x=0.8; y=0.8}   Outside
Mar 07 16:35:31 ObjcTest[2354] {x=1; y=1}       Inside
Mar 07 16:35:31 ObjcTest[2354] {x=1.2; y=1.2}   Outside
Mar 07 16:35:31 ObjcTest[2354] {x=1.4; y=1.4}   Outside
Mar 07 16:35:31 ObjcTest[2354] {x=1.6; y=1.6}   Outside
Mar 07 16:35:31 ObjcTest[2354] {x=1.8; y=1.8}   Outside
Mar 07 16:35:31 ObjcTest[2354] {x=2; y=2}       Outside
Mar 07 16:35:31 ObjcTest[2354] {x=2.2; y=2.2}   Outside



thanks,
Christian



reply via email to

[Prev in Thread] Current Thread [Next in Thread]