Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
extension CAEmitterLayer {
convenience init(image: CGImage) {
self.init()
let cell: CAEmitterCell = {
let cell = CAEmitterCell()
cell.birthRate = 40
cell.contents = image
cell.emissionLongitude = .pi / 2.0
cell.emissionRange = CGFloat.pi / 4.0
cell.lifetime = 16
cell.scale = 0.3
cell.scaleRange = 0.2
cell.velocity = 80
return cell
}()
emitterCells = [cell]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment