2014-02-14 23 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