Get random CGPoint on CGPath
问题 I have a CGPath that represents an ellipse. I'd like to place a sprite node at a random point on that path. How can I get a random CGPoint on that CGPath? 回答1: Speaking about a closed CGPath and thinking to a fast method to obtain a random point between infinite points inside a CGPath , first of all I've translated to Swift this: extension CGPath { func forEach(@noescape body: @convention(block) (CGPathElement) -> Void) { typealias Body = @convention(block) (CGPathElement) -> Void func