I've been using the following code to draw the user input in my basic paint application:
CGContextRef drawSpace = CGLayerGetContext(currentLayer);
CGContextBeginPath(drawSpace);
CGContextMoveToPoint(drawSpace, [[self.currentStroke objectAtIndex:0]pointValue].x, [[self.currentStroke objectAtIndex:0]pointValue].y);
for (NSValue *v in self.currentStroke) {
CGContextAddLineToPoint(drawSpace, [v pointValue].x ,[v pointValue].y);
/* CGContextMoveToPoint(drawSpace, [v pointValue].x ,[v pointValue].y);
The link I got only showed this called when index = 0, so I dummied it out. Left in,
it produces the original jagged image behavior */
}
CGContextClosePath(drawSpace);
CGContextSetStrokeColorWithColor(drawSpace, [[NSColor blackColor]CGColor]);
CGContextSetLineWidth(drawSpace, self.BrushSize); //Sets the brush size
CGContextStrokePath(drawSpace); //Strokes the path to the layer
Which works fine at small line widths, but at large sizes the image comes out like the drawing below. I know it has to do with the angles, but I have no idea how to rectify this problem. Does anyone know how I can get a clean stroke at any size?