Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c ios-从手指到手指的画笔移动_Objective C_Ios_Core Graphics_Quartz Core - Fatal编程技术网

Objective c ios-从手指到手指的画笔移动

Objective c ios-从手指到手指的画笔移动,objective-c,ios,core-graphics,quartz-core,Objective C,Ios,Core Graphics,Quartz Core,我想在我的iPad应用程序中画图,如下图所示 在我的应用程序中,我放置了一个图像,在移动手指(触摸运动)时,我重复这些图像,但我的图像似乎如下所示 下面是我绘制图像的代码 CGBlendMode blendMode = kCGBlendModeColorDodge; UIGraphicsBeginImageContext(drawImage.frame.size); [drawImage.image drawInRect

我想在我的iPad应用程序中画图,如下图所示

在我的应用程序中,我放置了一个图像,在移动手指(触摸运动)时,我重复这些图像,但我的图像似乎如下所示

下面是我绘制图像的代码

            CGBlendMode blendMode = kCGBlendModeColorDodge;
            UIGraphicsBeginImageContext(drawImage.frame.size);
            [drawImage.image drawInRect:CGRectMake(0, 0, drawImage.frame.size.width, drawImage.frame.size.height)];
            CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);

////            NSString *imagePath = [[NSBundle mainBundle] pathForResource:@"Watercolor-edge-45x45.png" ofType:nil];
            UIImage * textureColor;// = [UIImage imageWithContentsOfFile:imagePath];
            float angle = hypot(deltaX, deltaY);
            angle *= rand() % 180;//(M_PI / 180);
            CGPoint vector = CGPointMake(currentPoint.x - lastPoint.x, currentPoint.y - lastPoint.y);
            CGFloat distance = hypotf(vector.x, vector.y);
            vector.x /= distance;
            vector.y /= distance;
            for (CGFloat i = 0; i < distance; i += 1.0f) {
                textureColor = [UIImage imageWithCGImage:[self CGImageRotatedByAngle:image angle:angle * -1]];
                CGPoint p = CGPointMake(lastPoint.x + i * vector.x, lastPoint.y + i * vector.y);
                [textureColor drawAtPoint:p blendMode:blendMode alpha:0.1f];
            }
            CGContextBeginPath(UIGraphicsGetCurrentContext());
            CGContextStrokePath(UIGraphicsGetCurrentContext());
            UIImage *newimage = UIGraphicsGetImageFromCurrentImageContext();
            UIGraphicsEndImageContext();
CGBlendMode blendMode=kCGBlendModeColorDodge;
UIGraphicsBeginImageContext(drawImage.frame.size);
[drawImage.image drawInRect:CGRectMake(0,0,drawImage.frame.size.width,drawImage.frame.size.height)];
CGContextSetLineCap(UIGraphicsGetCurrentContext(),kCGLineCapRound);
////NSString*imagePath=[[NSBundle mainBundle]pathForResource:@“Watercolor-edge-45x45.png”,类型:nil];
UIImage*纹理颜色;//=[UIImage imageWithContentsOfFile:imagePath];
浮动角度=海压(三角洲、三角洲);
角度*=兰德()%180//(M_-PI/180);
CGPoint vector=CGPointMake(currentPoint.x-lastPoint.x,currentPoint.y-lastPoint.y);
CGFloat距离=hypotf(向量x,向量y);
向量x/=距离;
向量y/=距离;
对于(CGFloat i=0;i
如何获得第一个图像中的“我的图像”

事实上,我有一个图像,将选定的颜色填充到图像中,并开始在这里绘制我有一个图像

是否将画笔颜色更改为红色?很难说,他们可能有自己的艺术混合模式和随机变化的画笔。首先,它们从更饱和的颜色(更高的alpha)开始,你的看起来更像喷枪。你如何设置颜色而不是将颜色设置为绿色你设置[UIColor colorWithPatternImage:[UIImage IMAGENAME:@“pattern2.jpg”]]这样的颜色,你的图像会更小…嗨,谢谢你的反馈,在上文中,我已使用此CGContextSetLineCap(UIGraphicsGetCurrentContext(),kCGLineCapRound)编辑了您的问题;你可以试试这两个值kCGLineCapButt,kCGLineCapSquareya,我改变了这些类型,但我还是没有得到形状,你能帮我吗