Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to discover if 2 CGPath roteted rects intersect?
    primarykey
    data
    text
    <p>I am building 2 rects when view controller is loaded, using <code>CGPath</code>. The rects can be moved with <code>PanGestureRecognizer</code>. The question is how can I know when 2 rects had met? In order to not let them intersect?</p> <p><strong>MainViewController.m</strong></p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; for (int i=0; i&lt; 2; i++) { //create rects of CGPath CGRectCustomView* randomColorRect = [[CGRectCustomView alloc]initWithFrame: CGRectMake(&lt;random place on screen&gt;)]; //random angle randomColorRect.transform = CGAffineTransformMakeRotation (DegreesToRadians([Shared randomIntBetween:0 and:360])); [self.view addSubview:randomColorRect]; } } - (BOOL)areRectsCollide { ???How to find this??? } </code></pre> <p><strong>CGRectCustomView.m:</strong></p> <pre><code>- (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetLineWidth(context, 8.0); CGContextStrokePath(context); // do actual stroking CGContextSetRGBFillColor(context, &lt;green color&gt;, 1); CGContextFillRect(context, CGRectMake(self.frame.origin.x, self.frame.origin.y, self.frame.size.width, self.frame.size.height)); path = CGContextCopyPath(context); } </code></pre> <p>In Apple guide <a href="https://developer.apple.com/library/ios/documentation/2DDrawing/Conceptual/DrawingPrintingiOS/BezierPaths/BezierPaths.html" rel="nofollow">here</a>, there is a function that determines if a path contains point </p> <p><code>- (BOOL)containsPoint:(CGPoint)point onPath:(UIBezierPath *)path inFillArea:(BOOL)inFil</code>,</p> <p>but I have a rectangle which is endless number of points. So what should I do? Breaking my head... </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload