Skip to content

Instantly share code, notes, and snippets.

@laevandus
Last active January 6, 2019 10:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laevandus/a8ecc1de70c4ed43be8dc6facc8d4fb2 to your computer and use it in GitHub Desktop.
Save laevandus/a8ecc1de70c4ed43be8dc6facc8d4fb2 to your computer and use it in GitHub Desktop.
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