uibezierpath

Draw ellipse with start and end angle in Objective-C

醉酒当歌 提交于 2019-12-20 23:28:19
问题 I am writing an iPad app in which I am rendering XML objects that represent shapes into graphics on the screen. One of the objects I am trying to render is arcs. Essentially these arcs provide me with a bounding rectangle as well as a start and end angle. Given attributes: x y width height startAngle endAngle With these values I need to draw the arc (which is essentially part of an ellipse). I can not use the following: UIBezierPath *arc = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(x,

How to Get the reverse path of a UIBezierPath

杀马特。学长 韩版系。学妹 提交于 2019-12-20 18:15:10
问题 self.myPath=[UIBezierPath bezierPathWithArcCenter:center radius:200 startAngle:0 endAngle:180 clockwise:YES]; (This much I was able to get up running with some web searching). I have this path. Now I want to fill the reverse of this path, so leaving this portion and filling everything else. How can I finish the coding? I don't have much info on this. The problem The area it is showing after using Cemal Answer previously it only showed a circle with red stroke. Edit - (id)initWithFrame:(CGRect

iOS: UIBezierPath and CAShapeLayer fillRule

六眼飞鱼酱① 提交于 2019-12-20 10:59:08
问题 I have used both UIBezierPath and CAShapeLayer before. But almost every time in conjunction with filling the object contained within the path with color inside. But I would like this time to fill the color outside of the object contained by the UIBezierPath . I just wrote and ran the following simple code trying to get myself acquainted with the fillRule property: CAShapeLayer *myLayer = (CAShapeLayer*) self.layer; //size: 320 X 480 UIBezierPath *testPath = [UIBezierPath

UIBezierPath from image

放肆的年华 提交于 2019-12-20 09:25:06
问题 I have several png files that look similar to this this: Everything is transparent but the black path. What I am trying to do is create a UIBezierPath from the non transparent part. Edit: So I was thinking what about creating a mask with the png then from the mask go to a UIBezierPath. Would that work? Edit Again: I found the solution, look at my answer. 回答1: I went a different direction. Instead of using PNGs I went with SVG and used PocketSVG to parse the file. It works great. 回答2: The

Animated curve line in Swift 3

我的未来我决定 提交于 2019-12-20 09:07:19
问题 I want to draw some bezier lines and I want to animate them with a wave effect, Example Do you have some ideas about how I can do this ? Bezier line is it the best method to do it ? I found only 2 libs for this, but they are not really useful for what I need, I try to modify the code of one lib, unfortunately without success https://github.com/yourtion/YXWaveView I found this lib, https://antiguab.github.io/bafluidview/ which does the work, but it written in obj-c, maybe you know something

Eraser the drawing in iOS

我们两清 提交于 2019-12-20 07:13:06
问题 I am working on a drawing app, I have a UIBezeirPath, with which I draw in touchesMoved, and convert it to CGPath and then draw on to CGlayer, Here is my code -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { self.currentPath = [[DrawingPath alloc] init]; if(m_eraseButtonClicked) { [self.currentPath setPathColor:[UIColor backgroundColor]]; } else { [self.currentPath setPathColor:self.lineColor]; } CGPathRef cgPath = self.currentPath.path.CGPath; mutablePath =

Resize sprite without shrinking contents

送分小仙女□ 提交于 2019-12-20 04:22:10
问题 I have created a big circle with a UIBezierPath and turned it into a Sprite using this, let path = UIBezierPath(arcCenter: CGPoint(x: 0, y: 0), radius: CGFloat(226), startAngle: 0.0, endAngle: CGFloat(M_PI * 2), clockwise: false) // create a shape from the path and customize it let shape = SKShapeNode(path: path.cgPath) shape.lineWidth = 20 shape.position = center shape.strokeColor = UIColor(red:0.98, green:0.99, blue:0.99, alpha:1.00) let trackViewTexture = self.view!.texture(from: shape,

Draw a path with variable width in iOS

ぐ巨炮叔叔 提交于 2019-12-20 03:52:40
问题 I am working on a writing application, My writing is working fine, but what I want to implement is variable stroke width , so that the writing is very realistic and intuitive, as done by " BAMBOO " and " PENULTIMATE " application. Firstly I want to tell you what I have tried. 1) In iOS, their is no pressure detection, or velocity detection according to my research. For velocity detection, I have to use OPENGL. 2) Due to these limitations, I tried using the method given in this tutorial which

Get UIBezierPath Stroke's Outline Path

百般思念 提交于 2019-12-20 02:26:12
问题 I have a UIBezierPath stroke, now I want to get the stroke's outline path(not the stroke's path itself), is there a way I could get that? or at least NSLog the UIBezierPath stroke's outline path? Thanks 回答1: You can use CGPathCreateCopyByStrokingPath for this. UIBezierPath *path = ...; CGFloat lineWidth = 10; CGPathRef cgStrokedPath = CGPathCreateCopyByStrokingPath(path.CGPath, NULL, lineWidth, kCGLineCapRound, kCGLineJoinRound, 0); UIBezierPath *strokedPath = [UIBezierPath

How to create rounded UIButton with top-left & bottom-left corner radius only

吃可爱长大的小学妹 提交于 2019-12-20 01:12:13
问题 I need to create a button with top-left & bottom-left corner radius like this one . I tried by creating the following extension that was taken from one of stackoverflow answer: extension UIButton { func roundCorners(corners:UIRectCorner, radius: CGFloat) { self.layer.borderColor = GenerateShape.UIColorFromHex(0x989898, alpha: (1.0-0.3)).CGColor self.layer.borderWidth = 1.0 let path = UIBezierPath(roundedRect: self.bounds, byRoundingCorners: corners, cornerRadii: CGSize(width: radius, height: