cgpath

How to Animate a UIBezierPath

百般思念 提交于 2019-11-27 06:30:42
i would like to animate a UIBezierPath of a rect to a triangle one, not to animate a view on a path but animate the path itself so it morphs from one shape to another. the path is added to a CALayer CAShapeLayer *maskLayer = [CAShapeLayer layer]; maskLayer.fillColor = [[UIColor whiteColor] CGColor]; maskLayer.path = [self getRectPath]; -(CGPathRef)getTrianglePath { UIBezierPath* triangle = [UIBezierPath bezierPath]; [triangle moveToPoint:CGPointZero]; [triangle addLineToPoint:CGPointMake(width(self.view),0)]; [triangle addLineToPoint:CGPointMake(0, height(self.view))]; [triangle closePath];

Draw glow around inside edge of multiple CGPaths

故事扮演 提交于 2019-11-27 05:14:45
问题 If I create a CGMutablePathRef by adding together two circular paths as shown by the left image, is it possible to obtain a final CGPathRef which represents only the outer border as shown by the right image? Thanks for any help! 回答1: What you are asking for is the union of bezier paths. Apple doesn't ship any APIs for computing the union of paths. It is in fact a rather complicated algorithm. Here are a couple of links: http://www.cocoadev.com/index.pl?NSBezierPathcombinatorics http:/

CAShapeLayer Animating Path Glitches / Flickers (From Ellipse to Rect and back)

∥☆過路亽.° 提交于 2019-11-27 02:54:10
问题 I am running into an issue when I create an explicit animation to change the value of a CAShapeLayer's path from an ellipse to a rect. In my canvas controller I setup a basic CAShapeLayer and add it to the root view's layer: CAShapeLayer *aLayer; aLayer = [CAShapeLayer layer]; aLayer.frame = CGRectMake(100, 100, 100, 100); aLayer.path = CGPathCreateWithEllipseInRect(aLayer.frame, nil); aLayer.lineWidth = 10.0f; aLayer.strokeColor = [UIColor blackColor].CGColor; aLayer.fillColor = [UIColor

How to draw polygons with CGPath?

99封情书 提交于 2019-11-27 01:23:53
问题 I have been reading thru the documentation however it is not immediatly clear to me how to draw a polygon using CGPath. All I need to do is to draw CGPath around something like this: __ \ \ \ \ \__\ Could anyone please provide an snippet on how to do this? Additionally I assume CGPathContainsPoint will help me determine if a point is inside such path?, or does the path have to be a solid drawing Also how can i move the cgpath around? Is this as easy as changing something like the origin just

iOS Core Graphics: Draw ONLY shadows of a CGPath

时光总嘲笑我的痴心妄想 提交于 2019-11-27 00:31:13
问题 I am drawing a simple path in iOS 5 with Core Graphics: CGMutablePathRef path = CGPathCreateMutable(); CGPathMoveToPoint( path, NULL, center.x , topMargin ); CGPathAddLineToPoint(path, NULL, center.x+20, topMargin+50); CGPathAddLineToPoint(path, NULL, center.x , topMargin+40); CGPathAddLineToPoint(path, NULL, center.x-20, topMargin+50); CGPathAddLineToPoint(path, NULL, center.x , topMargin ); Now i want to fill it in Overlay mode like so: [[UIColor colorWithRed:0 green:0 blue:0 alpha:0.4]

Draw iOS 7-style squircle programmatically

落花浮王杯 提交于 2019-11-27 00:23:25
问题 I'm trying to find a way to draw a iOS 7-style icon 'squircle' shape programmatically, using core graphics. I'm not asking how to draw a rounded rectangle . A squircle is a superellipse: which is slightly different than a regular rounded rectangle: It's exact formula is readily available. However, I can't figure out how to draw this using, for example, a CGPath, let alone fill it, and be able to resize it rather easily. All this while being entirely exact with the formula. 回答1: Quote from

SpriteKit's SKPhysicsBody with polygon helper tool

好久不见. 提交于 2019-11-26 23:53:47
I wonder if there is a tool that could be used for easy generation of complex physics bodies in SpriteKit. I would like to have a volume based physical bodies with polygon-type shapes. SpriteKit allows to create such bodies with that method: + (SKPhysicsBody *)bodyWithPolygonFromPath:(CGPathRef)path Unfortunately it's time consuming task to generate such paths manually, and it could be problematic when testing. There is a SpriteHelper application that allows you to define body shape within easy-to-use visual editor, but this app can't export paths that could be used here. It was made for

1. CGPathMoveToPoint' is unavailable: Use move(to:transform:) 2. 'CGPathAddLineToPoint' is unavailable: Use addLine(to:transform:)

依然范特西╮ 提交于 2019-11-26 16:59:17
问题 I have created one of my application in swift 2 in Xcode 7.3.1 . But now I have open same application in Xcode 8.0 and perform changes. Some automatic changes are done and some errors and suggestions shown I have corrected them. But I am facing issue that let path = CGMutablePath() CGPathMoveToPoint(path, nil, lineFrame.midX, lineFrame.midY) CGPathAddLineToPoint(path, nil, lineFrame.origin.x + lineFrame.width / 2, lineFrame.origin.y) I tried to create path , but shows error that

Equivalent of or alternative to CGPathApply in Swift?

為{幸葍}努か 提交于 2019-11-26 16:17:32
问题 In the pre-release documentation there appears to be no Swift version of CGPathApply. Is there an equivalent or alternative? I'm trying to get all subpaths of a CGPath so that I can redraw it from a different starting point. 回答1: Swift 3.0 In Swift 3.0, you can use CGPath.apply like this: let path: CGPath = ... // or let path: CGMutablePath path.apply(info: nil) { (_, elementPointer) in let element = elementPointer.pointee let command: String let pointCount: Int switch element.type { case

Undo/Redo for drawing in iOS

試著忘記壹切 提交于 2019-11-26 14:47:07
问题 I am working on a drawing app, I want to do Undo/Redo, for this I am saving CGPath on touches ended to NSMutableArray, But I am not understanding how I should render the CGPaths on click of Undo button EDIT1: As I am using BezierPaths, So, I first decided to go with a simple approach of just stroking this path, without CGPath, EDIT2: As my Undo is happening in segments(i,e in parts and not whole path is deleted), I decided to create an array of array, So I have made changes accordingly and