title: Core graphics - Seams show on diagonally joined sides
body: <p>I'm having a problem in Core Graphics where two shapes that are supposed to fit together are showing seams between them when their sides are diagonal.  This is causing problems.  I can 'fix' this by overlapping the shapes.  This works for simple stuff, but when the shape is more complex things start to fall apart.</p>
  
  <p>Here is a simple example:</p>
  
  <pre><code>[[UIColor blackColor] setFill];
  [path fill]; //fills the entire background black
  
  UIBezierPath *path1 = [UIBezierPath bezierPath];
  [path1 moveToPoint:CGPointMake(0.0f, 0.0f)];
  [path1 addLineToPoint:CGPointMake(100, 0.0f)];
  [path1 addLineToPoint:CGPointMake(50, rect.size.height)];
  [path1 addLineToPoint:CGPointMake(0, rect.size.height)];
  [path1 closePath];
  UIBezierPath *path2 = [UIBezierPath bezierPath];
  [path2 moveToPoint:CGPointMake(100, 0)];
  [path2 addLineToPoint:CGPointMake(rect.size.width, 0)];
  [path2 addLineToPoint:CGPointMake(rect.size.width, rect.size.height)];
  [path2 addLineToPoint:CGPointMake(50, rect.size.height)];
  [path2 closePath];
  [[UIColor lightGrayColor] setFill];
  [path1 fill];
  [path2 fill];
  </code></pre>
  
  <p>This produces a seam that looks something like this:
  <img src="https://i.stack.imgur.com/HVoHZ.png" alt="ScreenShot of seam"></p>
  
  <p>This is exceptionally problematic because this is occurring in a <code>CGPathApply</code> call back function I'm using to process shapes (I divide the shapes up, do some processing and put them back together again).  Because of this, it's very difficult to determine how those shapes should be shifted in such a way as to remove the seams (by overlapping) without distorting the shape.  Especially since some of these shapes are rather complex (not simple rects).</p>
  
  <p>I did discover that turning off antialiasing (<code>CGContextSetShouldAntialias(context, NO);</code>) does remove the seems but things just get ugly if I do that, so it's not really an option.</p>
  
  <p>Any ideas?</p>