如何获取使用CGContextAddLineToPoint绘制的线的副本以获得Amizograph app之类的效果?

时间:2016-11-29 09:11:04

标签: ios drawing

我正在开发类似于Amaziograph的应用程序,也称为万花筒或曼陀罗。

这是我到目前为止所做的事情。

UITouch * touch = [触及anyObject];     CGPoint currentLocation = [touch locationInView:_imageDrawing];

UIGraphicsBeginImageContext(_imageDrawing.frame.size);
CGContextRef ctx = UIGraphicsGetCurrentContext();
[_imageDrawing.image drawInRect:CGRectMake(0, 0, _imageDrawing.frame.size.width, _imageDrawing.frame.size.height)];
CGContextSetLineCap(ctx, kCGLineCapRound);
CGContextSetLineWidth(ctx, 2.0);
CGContextSetRGBStrokeColor(ctx, red, green, blue, alpha);
CGContextBeginPath(ctx);

// Original track
CGContextMoveToPoint(ctx, location.x, location.y);
CGContextAddLineToPoint(ctx, currentLocation.x, currentLocation.y);

// Same x position different y
CGContextMoveToPoint(ctx, location.x, self.imageDrawing.frame.size.height - location.y);
CGContextAddLineToPoint(ctx, currentLocation.x, self.imageDrawing.frame.size.height - currentLocation.y);

// Same y position different x
CGContextMoveToPoint(ctx , self.imageDrawing.frame.size.width - location.x,location.y);
CGContextAddLineToPoint(ctx, self.imageDrawing.frame.size.width - currentLocation.x, currentLocation.y);

// different y position different x
CGContextMoveToPoint(ctx , self.imageDrawing.frame.size.width - location.x,self.imageDrawing.frame.size.height - location.y);
CGContextAddLineToPoint(ctx, self.imageDrawing.frame.size.width - currentLocation.x, self.imageDrawing.frame.size.height - currentLocation.y);

CGContextStrokePath(ctx);
_imageDrawing.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

location = currentLocation;enter image description here

是否有可用于开发Amizograph等应用程序的SDK?

以下是此应用的链接或如何手动实现此功能?

https://itunes.apple.com/us/app/amaziograph/id586076398?ls=1&mt=8 http://www.amaziograph.com/

由于

enter image description here enter image description here

0 个答案:

没有答案