2014-02-14 22 views
1

我一直在使用下面的代码来吸引用户输入我的基本涂料中的应用:石英线插去靠不住的,在一定的线宽

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 

在哪个小线宽工作正常,但在大尺寸图像如下图所示。我知道这与角度有关,但我不知道如何解决这个问题。有没有人知道我可以在任何尺寸下获得清洁的中风?

My drawing

回答

1

你在图片看到什么是核芯显卡绘制单一线段此起彼伏的结果。所以,当然不会画出线角,并且在大笔画宽度上显示的是这样的。

你应该做的是只有在完成绘制所有分段后才能划线。在这种情况下,运行时将为您处理角落。

另请参阅this question了解有关如何实施的更多信息。

+0

听起来不错,但用户使用鼠标进行绘图时应该显示什么内容? – PopKernel

+0

好吧,如果我是你,我会存储用户在单笔画中绘制的点,并在每次鼠标移动时重新绘制整条线。这应该给你你想要的结果。 – insys

+0

我试过了,但它不起作用。也许我做错了?我要更新问题... – PopKernel