在UIView上的接触点上绘制会在边界上产生模糊的绘制效果 [英] Drawing in UIView on touch points gives blurr drawing effect on boundaries
问题描述
要解决我的最后一个问题:在UIView的贝塞尔曲线路径中绘制/绘制类似草图颜色的颜色,我拍摄了精确的图像(路径),其中填充了所选颜色.然后,为了绘制UIView
中的上下文颜色,我进行了以下操作:
To sort out my last problem : Draw/Paint like sketch color inside a bezier path in UIView, I took an exact Image (of path) filled with selected color. Then, to draw that in UIView
, for context color I took:
lineColor=[UIColor colorWithPatternImage:img];
在drawrect中:
in drawrect :
CGPoint mid1 = midPoint(previousPoint1, previousPoint2);
CGPoint mid2 = midPoint(currentPoint, previousPoint1);
[curImage drawInRect:CGRectZero];
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);
CGContextSetBlendMode(context, kCGBlendModeCopy);
CGContextSetLineJoin(context, kCGLineJoinRound);
CGContextSetLineWidth(context, self.lineWidth);
CGContextSetStrokeColorWithColor(context,lineColor.CGColor);
CGContextSetShouldAntialias(context, YES);
CGContextSetAllowsAntialiasing(context, YES);
CGContextSetFlatness(context,0.5);
CGContextSetAlpha(context, 1.0);
CGContextStrokePath(context);
它完全沿视线绘制,但是在边界上颜色像融化效果一样消失.
It draws exactly in the path of view but on boundaries the color goes out like melting effect.
必须填充颜色的源图像:
Source Image in which color has to be filled :
用作colorWithPatternImage(img)的图像
image to be used as colorWithPatternImage (img)
触摸后,结果图像:
After drawing on touches ,resultimg Image :
我在这里想完全填满什么? 我们非常欢迎您提供有关核心图形的任何帮助! 谢谢!
What am I missing here to fill it perfectly? Any help with core graphics is most welcomed! Thank You!
为了掩盖图像,我也做了:
To mask the image I also did :
-(void)clipView :(MyUIBezierPath*)path drawingView:(DrawingView*)myView
{
MyUIBezierPath *myClippingPath =path;
CAShapeLayer *mask = [CAShapeLayer layer];
mask.path = myClippingPath.CGPath;
myView.layer.mask = mask;
}
但是colorWithPatternImage和这种遮罩可以实现相同的效果,即让我仅在路径内部进行绘制,我现在面临的问题是:它对在路径边界周围的接触点上绘制产生了不良影响!
But colorWithPatternImage and this masking does the same trick i.e lets me draw only inside the path , the problem I am facing now is : It gives a bad effect on drawing on touch points around the boundaries of path !
推荐答案
通过colorWithPatternImage与我自己的遮罩方法配合使用,尽管通过剪切遮罩是同一回事.绘画问题是因为图像是在触摸点绘制的在方法"calculateMinImageArea:CGPoint1:CGPoint2:CGPoint3"中.更改其尺寸(根据线宽的高度-宽度)将其分类.
Well its working with my own masking method via colorWithPatternImage , though masking it by clipping is the same thing.Drawing issue was because of the image being drawn at touch point in the method "calculateMinImageArea: CGPoint1 :CGPoint2 :CGPoint3". Changing its dimensions (height-width according to line width) sorts it out.
这篇关于在UIView上的接触点上绘制会在边界上产生模糊的绘制效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!