cgpath

Making an image follow a pre defined path in iPhone?

断了今生、忘了曾经 提交于 2020-01-02 11:04:29
问题 I am looking for some way to make an image (a ball) move along a predefined path in iPhone. My intention is to create a ball movement similar to the labyrinth movement. I understand there is a way to create paths programmatically using CGPath. But I believe it is difficult to create complex paths. Is there a better and easier way to create a path out of an image (which will look or represent a path) and make the image (ball) movement constrained in this path ? Thanx in advance for help ...

Gradient ALONG a CGPath

人走茶凉 提交于 2020-01-02 06:27:21
问题 I am drawing an arc that is an almost complete circle: CGContextSetFillColorWithColor(context, [UIColor whiteColor].CGColor); CGMutablePathRef path = CGPathCreateMutable(); CGPathMoveToPoint(path, NULL, centerPoint.x, centerPoint.y); CGPathAddArc(path, NULL, centerPoint.x, centerPoint.y, radius, (float)(3.0f * M_PI_2), radians, !clockwise); CGPathCloseSubpath(path); CGContextAddPath(context, path); CGContextFillPath(context); CGPathRelease(path); I have an arc like path that is an almost

Is it possible to add a UILabel or CATextLayer to a CGPath in Swift, similar to Photoshop's type to path feature?

血红的双手。 提交于 2020-01-02 00:12:59
问题 I would like to add text, whether it be a UILabel or CATextLayer to a CGPath . I realize that the math behind this feature is fairly complicated but wondering if Apple provides this feature out of the box or if there is an open-source SDK out there that makes this possible in Swift. Thanks! Example: 回答1: You'll need to do this by hand, by computing the Bezier function and its slope at each point you care about, and then drawing a glyph at that point and rotation. You'll need to know 4 points

How to import/parse SVG into UIBezierpaths, NSBezierpaths, CGPaths? [closed]

若如初见. 提交于 2019-12-31 09:43:30
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago . I am trying to import paths from a vector drawing program into the ios environment. I would like to get them into CGpaths or UIbezierpaths. I am most interested in importing paths from adobe illustrator. The best way seems to save as an svg and then import. I have found some

swift 3 CGPathAddCurveToPoint

坚强是说给别人听的谎言 提交于 2019-12-25 18:21:55
问题 I'm trying to update code to swift 3 but I can't find anything about CGPathAddCurveToPoint, how can I fix the error? path is a CGMutablePath CGPathAddCurveToPoint(path, nil, 10, 10, 20, 20, 30, 30) error: nil is not compatible with expected argument type 'UnsafePoiter' I found that CGPathAddLineToPoint(path, nil, 10, 10) became path.addLine(to: p0) 回答1: Please read the CGMutablePath docs: https://developer.apple.com/reference/coregraphics/cgmutablepath You will find: func addCurve(to end:

iphone stroke path used for clipping UIImage

雨燕双飞 提交于 2019-12-24 21:02:31
问题 I'm very new to CoreGraphics (although I've been doing iphone programming for a while) Question, I have this snippet that scales proportionally and clips an UIImage to a circle: -(UIImage *)counterpartImageForSchedule:(Schedule *)counterpartSchedule inSize:(CGSize)size { // This function returns a newImage, based on image, that has been: // - scaled to fit in (CGRect) rect // - and cropped within a circle of radius: rectWidth/2 UIImage *image=[UIImage imageNamed:@"fakeuser1.png"]; // when

Getting all points (not only control points) from UIBezierPath

∥☆過路亽.° 提交于 2019-12-24 11:35:35
问题 I have a UIBezierPath which i defined, and i can access the relevant points defined. Now, i want to extract all the points in the line, not just the points i defined. I saw these following questions: Question 1 Question 2 And i was wondering if using the answers selected will give the result i want, meaning: 1) Extract all points (already have them) as suggested in question 1 2) Calculate all the points between each pair (or triplet) of points as suggested in question 2 Is this the right

Fitting UIBezierPath/CGPath to circle

限于喜欢 提交于 2019-12-24 07:27:38
问题 I need to aspectFit arbitrarily shaped paths to the interior of a circle. I can fit rectangular paths to the circle by calculating the size, building a dest rect, then scaling the path to fit the dest rect. let targetSize = circleDiameter / sqrt(2) let destRect = CGRect(x: 0, y: 0, width: targetSize, height: targetSize) // ... Scale the path to the rect, using boundingBox of path. But the scaling process isn't the issue; it's really how to calculate the required scale. A bounding-box based

How to create CGPath from a SKSpriteNode in SWIFT

爷,独闯天下 提交于 2019-12-24 00:52:05
问题 I have a SKSpriteNode create with the level generator. I need to create exactly the same shape using CGPath. self.firstSquare = childNodeWithName("square") as! SKSpriteNode var transform = CGAffineTransformMakeRotation(self.firstSquare.zRotation) let rect = CGRect(origin: self.firstSquare.position, size: self.firstSquare.size) let firstSquareCGPath:CGPath=CGPathCreateWithRect(rect, &transform) print(self.firstSquare.position) => firstSquare position (52.8359451293945, -52.9375076293945) To

Keep relative positions of SKSpriteNode from SKShapeNode from CGPath

混江龙づ霸主 提交于 2019-12-24 00:46:44
问题 I have an array of array of coordinates (from a shapefile), which I'm trying to make into a series of SKSpriteNodes. My problem is that I need to keep the relative positions of each of the shapes in the array. If I use SKShapeNodes, it works, as they are just created directly from the path I trace, but their resources consumption is quite high, and, in particular I cannot use lighting effects on them. If I use SKSpriteNodes with a texture created from the shape node, then I lose their