cgpath

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

和自甴很熟 提交于 2019-12-02 19:25:49
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 resources for parsing exported SVG files that describe the paths. However, everything I have found only deals with absolute paths and not relative paths. The path below has capital C's and lowercase C's. I know how to parse the capital C (absolute paths) but I have no idea how to parse the lowercase c's (relative paths) I

How to animate a human written stroke using Swift/iOS?

我与影子孤独终老i 提交于 2019-12-02 14:18:00
Objective I am attempting to create an animated approximation of human writing, using a UIBezierPath generated from a glyph. I understand and I have read the many UIBezierPath questions which sound similar to mine (but are not the same). My goal is to create an animation that approximates the look of a human performing the writing of characters and letters. Background I've created a playground that I am using to better understand paths for use in animating glyphs as if they were drawn by hand. A couple of concepts in the Apple CAShapeLayer (strokeStart and strokeEnd) really don't seem to

CGPath is not detected properly in cocos2d

只愿长相守 提交于 2019-12-02 01:23:45
Through help and suggestions, I created a path for my sprite so that only the non-transparent parts can be touched. This is the path I came up with: path = CGPathCreateMutable(); CGPathMoveToPoint(path, NULL, endTouch.x, endTouch.y); CGPathAddLineToPoint(path, NULL, 0, 250); CGPathAddLineToPoint(path, NULL, 30, 0); CGPathCloseSubpath(path); This works for all my other classes except for one. No matter where I tap, xcode keeps printing "outside" using this code: for(int i = 0; i < [sprArray count]; i++) { CCSprite *sprite = (CCSprite *)[sprArray objectAtIndex:i]; if(CGRectContainsPoint([sprite

Create endless cgpath without framedrops

三世轮回 提交于 2019-12-01 15:15:21
问题 I need to create a cgpath continuously. At the moment I do it like that: func createLine(){ var rand = randomBetweenNumbers(1, 2) currentY-- if rand < 1.5{ currentX-- CGPathAddLineToPoint(leftPath, nil, currentX, currentY) }else{ currentX++ CGPathAddLineToPoint(leftPath, nil, currentX, currentY) } CGPathAddLineToPoint(rightPath, nil, currentX+tileSize, currentY) lineNode.path = leftPath rightNode.path = rightPath } And call it like that: NSTimer.scheduledTimerWithTimeInterval(0.05, target:

Masking CGContext with a CGPathRef?

十年热恋 提交于 2019-12-01 01:32:31
问题 I am doing some drawing using a CGContext. I am currently masking the drawing using a png file like this: UIImage * myImage = [UIImage imageNamed:@"frame.png"]; CGContextRef context = UIGraphicsGetCurrentContext (); CGContextClipToMask(context, self.view.bounds, myImage.CGImage); This works fine, but now I'd like to use an existing CGPathRef as my mask. Should I look at converting the CGPathRef to a UIImage and mask as above? If so how would I go about doing the conversion? -OR- Is there a

Core Text: Render to an Odd Shape

老子叫甜甜 提交于 2019-11-30 22:06:40
I am trying to render text to a shape that isn't a rectangle. The following code works when I add a rectangular path but not when I add an elliptical path. Ultimately, I'd like to draw to any path (L shape, etc), has anyone had any luck with this? -(void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetTextMatrix(context, CGAffineTransformIdentity); CGMutablePathRef path = CGPathCreateMutable(); float w = 200.0; float h = 300.0; CGRect bounds = CGRectMake(10.0, 10.0, w, h); // I draw using only one of the following lines CGPathAddRect(path, NULL, bounds

Merge multiple CGPaths together to make one path

南笙酒味 提交于 2019-11-30 10:44:06
问题 I am making a complex shape using a few CGRects and Ellipses. I would like to stroke that path once it has been created. When I stroke the path it strokes each shape. Is there a way I can merge each shape into a single path, so the stroke doesn't intersect? int thirds = self.height / 3; CGPathRef aPath = CGPathCreateMutable(); CGRect rectangle = CGRectMake((58 - 10) / 2, 46, 10, self.height - 58); CGPathAddRect(aPath, nil, rectangle); CGPathAddEllipseInRect(aPath, nil, CGRectMake((58 - 48) /

Frame and Bounds of CAShapeLayer

好久不见. 提交于 2019-11-30 08:57:16
I am working on CAShapeLayer .And trying to draw non-linear path.I want to set frame to CAShapeLayer .So i can use CGPathGetPathBoundingBox method to get frame from CGPathRef . Here is code : CGMutablePathRef path = CGPathCreateMutable(); CGPathAddArc(path, NULL, rect.size.width/2, rect.size.height/2, 100, (0), (M_PI_2), NO); CGPathAddArc(path, NULL, rect.size.width/2, rect.size.height/2, 100-50, (M_PI_2), (0), YES); CGPathCloseSubpath(path); CAShapeLayer* arcLayer = [[CAShapeLayer alloc]init]; arcLayer.path = path; arcLayer.frame = CGPathGetPathBoundingBox(path); arcLayer.bounds =

CABasicAnimation with CALayer path doesn't animate

笑着哭i 提交于 2019-11-30 07:52:50
问题 I'm trying to animation the transition of a CALayer from normal corners to rounded corners. I only want to round the top corners, so I am using a UIBezierPath. Here's the code: UIRectCorner corners = UIRectCornerTopLeft | UIRectCornerTopRight; UIBezierPath* newPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:corners cornerRadii:CGSizeMake(8.0f, 8.0f)]; UIBezierPath* oldPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:corners cornerRadii

Draw Rectangle/ Circle and Triangle in Spritekit with Two Colors. . .

只谈情不闲聊 提交于 2019-11-30 05:30:41
问题 I can draw Rectangle using simple SKSpriteNode. But i can not draw other types of drawings in it like Triangle, Circle etc with TWO SPLIT COLORS. Someone suggested to go with CGPath. But i am newbie and dont know to draw such type of complex things . Please can anyone illustrate simple way to go with these drawings with MULTICOLOR in SPRITEKIT. Mean their upper part is one color and lower part in 2nd color. More concise to say that Shape is divided into two colors whether that is star,