uibezierpath

UIBezierPath intersect

不想你离开。 提交于 2019-11-27 15:38:52
I've been searching for an answer for hours but have trouble finding anything on the topic. I have a question related to Objective-c. I'm making an application in which a UIView checks for touches from the user and if the user touches and moves his/her finger, a path using UIBezierPath is drawn. If the user draws so that the path intersects itself it should disappear from the screen. When the user is done drawing the pattern, a line from the last point in the path should connect with the first point in the path automatically (I'm using the method "closePath" for this), if this line intersects

UIBezierPath Multiple Line Colors

喜你入骨 提交于 2019-11-27 14:50:46
My attempt to draw UIBezierPath lines with different colors is failing me. All the lines change to the currently selected color. All my path and information are all stored in an NSMutableArray called pathInfo. In path info I drop in array that contains the Path, Color, Width, and Type of line. This works fine except all the lines turn to whatever color the user has selected. I would appreciate any help greatly! - (void)drawRect:(CGRect)rect { UIBezierPath *drawPath = [UIBezierPath bezierPath]; drawPath.lineCapStyle = kCGLineCapRound; drawPath.miterLimit = 0; for (int i = 0; i < [pathInfo count

Union UIBezierPaths rather than apend path

﹥>﹥吖頭↗ 提交于 2019-11-27 14:44:11
I have an app where I take a UIBezierPath and use it as a brush by a series of appendPath: calls. After a few goes and with really complex brush shapes the memory runs out and the app grinds to a halt. What I really want to do is a full on union exactly like Paint Code does but I can't find any way of doing this. How would I go about unioning two or more UIBezierPaths? EDIT: Here is a visual of what I want to achieve dynamically. In Paint Code you take two paths and overlap them like this: BUT I want to merge / union them into one new single path like: Note that in the bottom panel of Paint

UIBezierPath doesn't work in TopRight corner and BottomRight corner

三世轮回 提交于 2019-11-27 14:26:52
I want to round my right corners, but only works for Left corners let path = UIBezierPath(roundedRect: view.bounds, byRoundingCorners: [UIRectCorner.TopLeft, UIRectCorner.TopRight], cornerRadii: CGSizeMake(20.0, 20.0)) let maskLayer = CAShapeLayer() maskLayer.path = path.CGPath view.layer.mask = maskLayer view.layer.masksToBounds = true The problem is that you're getting the view's bounds before it's been resized for the current device. It's larger than it will be later when it appears on screen, so the right side of your rounded rect is off the right side of the screen. You need to create

IOS : Animate transformation from a line to a bezier curve

假装没事ソ 提交于 2019-11-27 09:47:56
问题 I would like to animate a straight line curving into a bezier curve (from "_" to "n"), is there a library somewhere that can help me to do it ? I know how to draw a Bezier curve with UIBezierPath, I could redraw rapidly and progressively do the transformation, but if something already does that it would be cool :-) 回答1: I might do something with a CADisplayLink . For example, you could do this in your view controller using a CAShapeLayer , e.g.: #import "ViewController.h" #import <QuartzCore

Apply gradient color to arc created with UIBezierPath

懵懂的女人 提交于 2019-11-27 09:30:14
问题 I want to create a progress bar that has the form of an arc. The color of the progress bar has to change according to the values. I created an arc using UIBezierPath bezierPathWithArcCenter . I used the following code: - (void)viewDidLoad { [super viewDidLoad]; int radius = 100; CAShapeLayer *arc = [CAShapeLayer layer]; arc.path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(100, 50) radius:radius startAngle:60.0 endAngle:0.0 clockwise:YES].CGPath; arc.position = CGPointMake

Multitouch tracking issue

爱⌒轻易说出口 提交于 2019-11-27 08:05:05
问题 I am working with multitouch while writing, So basically what I am doing is, I am writing with hand support, because typically, its how user rights, I followed this link How to ignore certain UITouch Points in multitouch sequence So, what I am doing is , I am tracking a touch Object in touchesBegan and using that only in touchesMoved.Everything works fine, but some times while writing, I get this line In the above image, you can see the thick line which suddenly comes while writing with my

Calculate controlPoints while drawing in iOS

六月ゝ 毕业季﹏ 提交于 2019-11-27 07:11:13
问题 I am working on a drawing app, where user can draw/write with his finger or stylus. For this I have referred code from https://github.com/yusenhan/Smooth-Line-View , in my application. The problem which I am facing is that, the writing sometimes when you write very closely is not very smooth. So I think, I am making some mistake in getting the control point. Below is my code //Find the midpoint CGPoint midPoint(CGPoint p1, CGPoint p2) { return CGPointMake((p1.x + p2.x) * 0.5, (p1.y + p2.y) *

Detecting tap inside a bezier path

泄露秘密 提交于 2019-11-27 06:42:53
问题 I have a UIView which is added as a subview to my view controller. I have drawn a bezier path on that view. My drawRect implementation is below - (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); UIBezierPath *bpath = [UIBezierPath bezierPath]; [bpath moveToPoint:CGPointMake(50, 50)]; [bpath addLineToPoint:CGPointMake(100, 50)]; [bpath addLineToPoint:CGPointMake(100, 100)]; [bpath addLineToPoint:CGPointMake(50, 100)]; [bpath closePath]; CGContextAddPath

How to crop the image using UIBezierPath?

a 夏天 提交于 2019-11-27 06:38:15
I want to get the image from the UIBezierpath closed path(See the image). I draw the image on the UIView using drawRect method and also draw the lines are using the drawRect method. How can I get the particular closed path image? Please help me. Thanks in advance. This code used for draw the bezierpath. UIBezierPath *aPath = [UIBezierPath bezierPath]; for (NSString *pointString in pointArray) { if ([pointArray indexOfObject:pointString] == 0) [aPath moveToPoint:CGPointFromString(pointString)]; else [aPath addLineToPoint:CGPointFromString(pointString)]; } [aPath closePath]; iDev You can use a