Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save SarahAlsharif/c152cd05ff00dc50cef6cd90f547ea75 to your computer and use it in GitHub Desktop.
Save SarahAlsharif/c152cd05ff00dc50cef6cd90f547ea75 to your computer and use it in GitHub Desktop.
struct LikesGeometryEffect : GeometryEffect {
var time : Double
var speed = Double.random(in: 100 ... 200)
var xDirection = Double.random(in: -0.05 ... 0.05)
var yDirection = Double.random(in: -Double.pi ... 0)
var animatableData: Double {
get { time }
set { time = newValue }
}
func effectValue(size: CGSize) -> ProjectionTransform {
let xTranslation = speed * xDirection
let yTranslation = speed * sin(yDirection) * time
let affineTranslation = CGAffineTransform(translationX: xTranslation, y: yTranslation)
return ProjectionTransform(affineTranslation)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment