पर चिकना लेखन मैं वर्तमान में एक आईपैड प्रोजेक्ट पर काम कर रहा हूं जहां मुझे उपयोगकर्ता को स्टाइलस के साथ कागज के टुकड़े पर लिखने की कार्यक्षमता की आवश्यकता है।आईपैड
मैंने कुछ स्टाइलस का परीक्षण किया है और पता चला है कि बांस सबसे अच्छा था। उनके पास एक नि: शुल्क एप्लिकेशन भी है जिसका उपयोग आप लिखने के लिए कर सकते हैं।
मुझे जिस समस्या का सामना करना पड़ रहा है वह यह है कि मैं जिस विधि का उपयोग करता हूं वह चिकनी घटता नहीं प्रदान करता है। बांस पेपर ऐप सही दिखने वाली लाइनें प्रदान करता है। यह कोड मेरे पास अब तक है:
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
UIGraphicsBeginImageContext(self.frame.size);
// draw accumulated lines
if ([self.lines count] > 0) {
for (Line *tempLine in self.lines){
CGContextSetAlpha(context, tempLine.opacity);
CGContextSetStrokeColorWithColor(context, tempLine.lineColor.CGColor);
CGContextSetLineWidth(context, tempLine.lineWidth);
CGContextSetLineCap(context, kCGLineCapRound);
CGContextSetLineJoin(context, kCGLineJoinRound);
CGContextAddPath(context, tempLine.linePath);
CGContextStrokePath(context);
}
}
//draw current line
CGContextSetAlpha(context, self.currentLine.opacity);
CGContextSetStrokeColorWithColor(context, self.currentLine.lineColor.CGColor);
CGContextSetLineWidth(context, self.currentLine.lineWidth);
CGContextSetLineCap(context, kCGLineCapRound);
CGContextSetLineJoin(context, kCGLineJoinRound);
CGContextBeginPath(context);
CGContextAddPath(context, self.currentLine.linePath);
CGContextStrokePath(context);
UIGraphicsEndImageContext();
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint cPoint = [touch locationInView:self];
CGPathMoveToPoint(self.currentLine.linePath, NULL, cPoint.x, cPoint.y);
[self setNeedsDisplay];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint currentPoint = [touch locationInView:self];
CGPathAddLineToPoint(self.currentLine.linePath, NULL, currentPoint.x, currentPoint.y);
[self setNeedsDisplay];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint cPoint = [touch locationInView:self];
CGPathAddLineToPoint(self.currentLine.linePath, NULL, cPoint.x, cPoint.y);
[self setNeedsDisplay];
[self.lines addObject:self.currentLine];
Line *nextLine = [[Line alloc] initWithOptions:self.currentLine.lineWidth color:self.currentLine.lineColor opacity:self.currentLine.opacity];
self.currentLine = nextLine;
[nextLine release];
}
यहां छवियां हैं जो यह स्पष्ट करती हैं कि मुझे किस समस्या का सामना करना पड़ रहा है।
यह अगर मैं Mamboo कागज एप्लिकेशन पर एक ही बात लिखने छवि है:: इस छवि को क्या उत्पन्न हो जाता है जब ऊपर दिया गया कोड के साथ लिखित रूप है
करता है किसी को भी यह पता है कि मम्बो ऐप में अच्छा लेखन कैसे प्राप्त किया जाए? CGPathAddCurveToPoint
या CGPathAddQuadCurveToPoint
:
[iPhone चिकनी स्केच ड्राइंग एल्गोरिथ्म] के संभावित डुप्लिकेट (http://stackoverflow.com/questions/5076622/iphone-smooth-sketch-drawing-algorithm) –
भी देखें [मैं कैसे छूने पर उंगली आंदोलन ट्रेस कर सकते हैं चिकनी घटता ड्राइंग के लिए?] (http://stackoverflow.com/questions/1052119/how-can-i-trace-the-finger-movement-on-touch-for-drawing-smooth-curves)। –
नमूना https: // github देखें।com/yusenhan/चिकना-रेखा-दृश्य –