Questions tagged [cgpath]

A graphics path is a mathematical description of a series of shapes or lines. CGPath defines an opaque type that represents an immutable graphics path.The issue related with this tag can be tagged using [tag:CGPath] in iOS

CGPath is available in apple "CoreGraphics" framework.CGPaths are how CoreGraphics describes the bezier paths it uses for drawing to the screen. They can go a long way to unlocking some of the power of CoreGraphics.

For More information:

CGPath related question in SO:

Related Tags:

446 questions
6
votes
2 answers

I can't fill my CGPath

I need some help with filling my path. I have no clue where to put CGContextFillPath(path); for example. I am pretty new to drawing (and iOS Development) and I really tried everything for nearly two hours now. But I reached the point where I just…
the_critic
  • 12,720
  • 19
  • 67
  • 115
6
votes
1 answer

Why CGPath and UIBezierPath define "clockwise" differently in SpriteKit?

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:…
Franklin Yu
  • 8,920
  • 6
  • 43
  • 57
6
votes
5 answers

Drawing dashed line in Sprite Kit using SKShapeNode

I fount this solution but I can't make it into swift code This what I try var pattern[2]:CGFloat; this var dashed: CGPathRef = CGPathCreateCopyByDashingPath(CGPathCreateCopyByDashingPath(path, transform, phase, lengths, count); var myShapeNode:…
user4460910
6
votes
2 answers

Drawing dashed line in Sprite Kit using SKShapeNode and CGPath

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 =…
Androyal
  • 893
  • 8
  • 7
6
votes
4 answers

Why does creating and removing SKShapeNode and SKNode repeatedly cause a memory leak?

Using the sprite kit template that comes with Xcode, I modify the scene to be as follows : #import "MyScene.h" @interface MyScene () @property (nonatomic,strong)SKNode *floor; @end @implementation MyScene -(id)initWithSize:(CGSize)size { …
Rahul Iyer
  • 19,924
  • 21
  • 96
  • 190
6
votes
2 answers

Inverse CGPath in Rect

I'm looking to inverse a CGPath (relative to a Rect). By this, I mean I have defined a CGPath and I want to get a CGPath that outlines all other areas in the rect. I've been experimenting different ways and been googling for a couple days now with…
Joshua
  • 197
  • 1
  • 10
6
votes
1 answer

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

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…
Programmer
  • 408
  • 1
  • 5
  • 15
6
votes
2 answers

finding a point on a path

I have an app that draws a bezier curve in a UIView and I need to find the X intersect when I set a value for Y. First, as I understand, there isn’t a way to find a point directly of a UIBezierPath but you can locate a point of a CGPath. First, if I…
Old Name
  • 273
  • 1
  • 3
  • 13
5
votes
3 answers

use CAEmitterLayer to draw particles around a circle or a CGPath

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…
cpprulez
  • 896
  • 2
  • 9
  • 21
5
votes
1 answer

How to move an UIView along a curved CGPath according to user dragging the view

I'm trying to build a interface that the user can move his finger around the screen an a list of images moves along a path. The idea is that the images center nevers leaves de path. Most of the things I found was about how to animate using CGPath…
Felipe Cypriano
  • 2,727
  • 22
  • 32
5
votes
2 answers

How do I remove a CAShapeLayer and CABasicAnimation from my UIView?

This is my code: @objc func drawForm() { i = Int(arc4random_uniform(UInt32(formNames.count))) var drawPath = actualFormNamesFromFormClass[i] shapeLayer.fillColor = UIColor.clear.cgColor shapeLayer.strokeColor = UIColor.black.cgColor …
5
votes
2 answers

Set Start Point for CGAffineTransform

I am animating a UIView along a circle using a CAKeyframeAnimation that follows a CGPathAddEllipseInRect. However, the view always seems to start in the same place regardless of the frame it is originally positioned in. Is there some way to adjust…
individualtermite
  • 3,615
  • 16
  • 49
  • 78
5
votes
1 answer

CGPath not working in Swift 3

I am updating code for swift 3. I have created a custom path for my spritekit object that works in swift 2. However, now I get a compiler error: Nil is not compatible with expected argument type 'Unsafe Pointer CGAffineTransform' let offsetX =…
patrickd
  • 275
  • 3
  • 14
5
votes
0 answers

Creating BezierPath from Texture in SpriteKit/Swift

So, basically, I have a sprite (.png) in SpriteKit, where most of the pixels are zero/no detail etc. I wish to create a UIBezierPath of only the detail inside the Sprite, so later I can use containsPoint. After a bunch of googling I found you can…
Reanimation
  • 3,151
  • 10
  • 50
  • 88
5
votes
1 answer

Cannot release path created by CGPathCreateMutable in Swift

I have this simple code in Swift: override var bounds : CGRect { didSet { if (bounds != oldValue) { var path = CGPathCreateMutable() CGPathAddEllipseInRect(path, nil, bounds) self.path = path CGPathRelease(path) } …
danqing
  • 3,348
  • 2
  • 27
  • 43