I am working on a Drawing App for iOS. In this app i need to draw textured lines. For this i am using this method.But texture is so small and not in shape.
I want to know what i did wrong and how can i resolve it.
Here is my updated code-
CGPoint mid1 = midPoint(previousPoint1, previousPoint2);
CGPoint mid2 = midPoint(currentPoint, previousPoint1);
[curImage drawAtPoint:CGPointMake(0, 0)];
CGContextRef context = UIGraphicsGetCurrentContext();
[self.layer renderInContext:context];
CGContextMoveToPoint(context, mid1.x, mid1.y);
CGContextAddQuadCurveToPoint(context, previousPoint1.x, previousPoint1.y, mid2.x, mid2.y);
CGContextSetLineCap(context, kCGLineCapRound);
CGContextSetLineJoin(context, kCGLineJoinRound);
CGContextSetLineWidth(context, self.lineWidth);
//trans layer
CGContextBeginTransparencyLayer(context, nil);//
CGRect rect=CGContextGetPathBoundingBox (context);//
CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor);//
//trans layer end
CGContextSetShouldAntialias(context, YES);
CGContextSetAllowsAntialiasing(context, YES);
CGContextSetFlatness(context, 0.1f);
CGContextSetAlpha(context, self.lineAlpha);
CGContextStrokePath(context);
//patter start
CGContextSetFillColorSpace(context, CGColorSpaceCreatePattern(NULL));
static const CGPatternCallbacks callbacks = { 0, &lightDataArea, NULL };
CGPatternRef hello = CGPatternCreate(NULL, rect, CGAffineTransformIdentity, 0, 0, kCGPatternTilingConstantSpacing, YES, &callbacks);
CGFloat alpha = 1;
CGContextSetFillPattern(context, hello, &alpha);
CGContextFillRect(context, rect);
//pattern end
//trans layer remaining
CGContextSetBlendMode(context, kCGBlendModeSourceIn);//
CGContextDrawImage(context, rect, [self image:[UIImage imageNamed:@"dddd.jpg"] withColor:[UIColor blueColor]].CGImage);//
CGContextEndTransparencyLayer (context);//
//trans layer end
CGPatterCallback -
void lightDataArea (void *info, CGContextRef context)
{
UIImage *image = [UIImage imageNamed:@"dddd.png"];
CGImageRef imageRef = [image CGImage];
CGContextDrawImage(context, CGRectMake(0, 0, 100, 100), imageRef);
}
This is what i am getting
my texture image
Still the same result. Help me please. I have very little knowledge about CG.