How to draw a signature with a pencil effect in Lens C?

I am trying to develop a new application based on paint effects. I know a simple effect, but I've seen an application with a brush effect (pencil effect).

how to do it? (SignNow App)

thank

Below is an example. (first with my code and second I want the same effect)

first:

myapp draws a signature

second:

signnow app i want nevertheless

my code:

- (void)drawRect:(CGRect)rect {

CGContextRef context = UIGraphicsGetCurrentContext();

// Set drawing params
CGContextSetLineWidth(context, self.lineWidth);
CGContextSetStrokeColorWithColor(context, [self.foreColor CGColor]);
CGContextSetLineCap(context, kCGLineCapButt);
CGContextSetLineJoin(context, kCGLineJoinRound);
CGContextBeginPath(context);




// This flag tells us to move to the point
// rather than draw a line to the point
BOOL isFirstPoint = YES;

// Loop through the strings in the array
// which are just serialized CGPoints
for (NSString *touchString in self.handwritingCoords) {

    // Unserialize
    CGPoint tapLocation = CGPointFromString(touchString);

    // If we have a CGPointZero, that means the next
    // iteration of this loop will represent the first
    // point after a user has lifted their finger.
    if (CGPointEqualToPoint(tapLocation, CGPointZero)) {
        isFirstPoint = YES;
        continue;
    }


    // If first point, move to it and continue. Otherwize, draw a line from
    // the last point to this one.
    if (isFirstPoint) {
        CGContextMoveToPoint(context, tapLocation.x, tapLocation.y);




            //CGContextAddArc(ctx, tapLocation.x, tapLocation.y, 30.00, (startDeg-90)*M_PI/180.0, (endDeg-90)*M_PI/180.0, 0);
        isFirstPoint = NO;
    } else {
        CGPoint startPoint = CGContextGetPathCurrentPoint(context);
        CGContextAddQuadCurveToPoint(context, startPoint.x, startPoint.y, tapLocation.x, tapLocation.y);
        CGContextAddLineToPoint(context, tapLocation.x, tapLocation.y);
    }

}   

// Stroke it, baby!
CGContextStrokePath(context);

      

}

+3


source to share


1 answer


I recommend getting inspiration from an active smooth-drawing project . This is a great place to start and learn the best practices. Also, you can read more about this project's mindset over the excellent article on drawing smooth lines with cocos2d .



0


source







All Articles