cgpath

use CAEmitterLayer to draw particles around a circle or a CGPath

血红的双手。 提交于 2019-12-06 03:58:08
问题 I'm trying to use iOS 5's particle system (CAEmitterLayer and CAEmitterCell) to draw particles around a circle (or even better, a CGPath), but I don't know how to do it. The best I could do is make an arc (by modifying the yAcceleration property of CAEmitterCell), but I can't do a complete circle. Of course, I could do multiple arcs to simulate a circle, but the "knots" are very visible. Also, I don't want to use masks, because it would seem like the particles at the edges are cropped. Any

Drawing dashed line in Sprite Kit using SKShapeNode and CGPath

假装没事ソ 提交于 2019-12-06 03:28:18
问题 I want to draw a dashed line in my sprite kit game, I can use SKShapeNode node to draw a normal line like the following: UIBezierPath *_path=[UIBezierPath bezierPath]; //1 CGPoint point1 = CGPointMake(100,100); CGPoint point2 = CGPointMake(150,150); [_path moveToPoint:point1]; [_path addLineToPoint:point2]; //2 SKShapeNode *line = [SKShapeNode node]; line.path = _path.CGPath; I tried to set a dashed pattern to UIBezierPath like this: // adding this code at location 1 or 2 above but no effect

Clearing CGPath path after drawing is done

烈酒焚心 提交于 2019-12-06 02:24:53
I've written a program for drawing in iOS in touchesMoved() method. CGContextAddPath(UIGraphicsGetCurrentContext(), path); CGPathMoveToPoint(path, NULL, lastPoint.x, lastPoint.y); CGPathAddLineToPoint(path, NULL, lastPoint.x, lastPoint.y); CGContextDrawPath(UIGraphicsGetCurrentContext(), kCGPathStroke); How can i clear the path drawn and restore the original view? Perhaps you can put an invisible view above your view of drawing and add the path traced by the user only when u are sure that the user will not undo. If the user wants the undo action, don't add the path to the context. Thats my

Can't set shadow on UICollectionViewCell and have rounded corners. Can only make one work at a time

吃可爱长大的小学妹 提交于 2019-12-05 21:32:57
I have a UICollectionViewCell subclass and I need to round its corners and add a shadow as well. The cell looks like a square card, and the cells have a good amount of space in-between them. So "underneath" every cell, I would like to add some shadow. I can successfully do this, but then my cell only has rounded corners on the bottom. The top just has normal corners. I need rounded corners for all four corners. I have found solutions on here for UIViews that recommend adding a separate UIView as a subview , but I would prefer to avoid this for performance reasons. I did find one solution which

Why CGPath and UIBezierPath define “clockwise” differently in SpriteKit?

荒凉一梦 提交于 2019-12-05 20:36:13
In SpriteKit, the clockwise direction is reversed for UIBezierPath but not for CGPath . For example, if I have do { let path = CGPathCreateMutable() CGPathAddArc(path, nil, 0, 0, 10, 0, CGFloat(M_PI_2), true) let node = SKShapeNode(path: path) node.position = CGPoint(x: self.size.width/2, y: self.size.height/2) self.addChild(node) } do { let path = UIBezierPath() path.addArcWithCenter(CGPoint(x: 0, y: 0), radius: 10, startAngle: 0, endAngle: CGFloat(M_PI_2), clockwise: true) let node = SKShapeNode(path: path.CGPath) node.position = CGPoint(x: self.size.width/2, y: self.size.height/2 - 100)

Gradient ALONG a CGPath

我只是一个虾纸丫 提交于 2019-12-05 16:09:45
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 complete circle. In this code it is all one color, however, I want one end to be a solid white color and

CGPath from image

天涯浪子 提交于 2019-12-05 08:01:01
问题 I need to create mask based on image (any possible shape). I need to: Create CALayer with CGPath as a proper mask Call [UIView.layer setMask: with layer above ] So main big question is how to set CGPath based on black-white image? Or is it possible to place mask directly from image? Thanks! Example image of a mask: 回答1: You will need to create your image with an alpha channel. According to CALayer 's mask property documentation: An optional layer whose alpha channel is used as a mask to

Move CGPathCreateMutable() so the path stays the same?

血红的双手。 提交于 2019-12-05 01:11:55
问题 I have got 9 hexagon sprites across the screen and I have to specify a certain path around them to make their area touchable. I don't want to set the coordinates for every single path respectively, so can't I just use the first path (the hexagons are all the same size) and move its origin to another position (without destroying the shape)? (If i do it now, the CGPathAddLineToPoint(); adds the points of the hexagon from the previous hexagon. I hope I got the idea across ... (see picture...

Setting correct frame of a newly created CAShapeLayer

血红的双手。 提交于 2019-12-04 16:16:46
问题 In short: Apple does NOT set the frame or bounds for a CAShapeLayer automatically (and Apple HAS NOT implemented an equivalent of [UIView sizeThatFits] ) If you set the frame using the size of the bounding-box of the path ... everything goes wrong. No matter how you try to set it, it screws-up the path So, what's the correct way to programmatically set the frame of a newly-created CAShapeLayer with a newly-added CGPath ? Apple's docs are silent on the matter. Things I've tried, that don't

Sprite Kit - SKShapeNode Path not drawing Quad Curve

被刻印的时光 ゝ 提交于 2019-12-04 16:12:00
问题 I have been delving in to Apple's new Sprite Kit, and been using it for a while now. However I ran into an issue when trying to draw a curved path for an SKShapeNode . It just appears to draw a straight line instead. Here is a very simple example of the issue I am having - experimenting with drawing a CGPath for an SKShapeNode : CGMutablePathRef path = CGPathCreateMutable(); CGPathMoveToPoint(path, NULL, 0, 0); CGPathAddQuadCurveToPoint(path, NULL, 50, 100, 100, 0); CGPathAddLineToPoint(path,