Guest User

CGContainsPoint in Scaling

a guest
Sep 11th, 2011
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CGAffineTransform at;
  2. CGContextRef context;
  3. CGPathRef ref;
  4.  
  5. - (void)drawRect:(CGRect)rect {
  6.     // Drawing code.
  7.  
  8.     context = UIGraphicsGetCurrentContext();
  9.        
  10.     at = CGAffineTransformMake(scale, rotate, rotate, scale, dragX+howMuchDraggedX, dragY+howMuchDraggedY);
  11.  
  12.     CGContextConcatCTM(context, at);
  13.  
  14.     for (int i=0; i<[arrayOfPaths count]; i++) {
  15.        
  16.         PathArea* pathValue = [arrayOfPaths objectAtIndex:i];
  17.            
  18.         CGContextAddPath(context, pathValue.pathRef);      
  19.     }
  20.  
  21.     CGContextFillPath(context);
  22.  
  23. }
  24.  
  25. -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
  26. {  
  27.     NSSet* setOfTouch = [event allTouches];
  28.    
  29.     UITouch *touch = [[setOfTouch allObjects] objectAtIndex:0];
  30.     CGPoint point = [touch locationInView:self];
  31.            
  32.     for (int i=0; i<[arrayOfPaths count]; i++) {
  33.  
  34.         PathArea* path = [arrayOfPaths objectAtIndex:i];
  35.  
  36.         CGAffineTransform trans = CGAffineTransformMakeScale(scale, scale);
  37.  
  38.         // It doesn't work !!!
  39.         NSLog(@"%d" ,CGPathContainsPoint(path.pathRef, &trans, point, TRUE));
  40.        
  41.         //  if i check it for dragging. It works!
  42.         //  CGAffineTransform trans =
  43.         //   CGAffineTransformMakeTranslation(-(dragX+howMuchDraggedX), -(dragY+howMuchDraggedY));
  44.         //  NSLog(@"%d" ,CGPathContainsPoint(path.pathRef, &trans, point, TRUE));
  45.  
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment