RamonGilabert / Walker

Each step you take reveals a new horizon. You have taken the first step today.
Other
150 stars 14 forks source link

CADisplayLink? #3

Open eonist opened 8 years ago

eonist commented 8 years ago

Hey,

First of all Awesome concept!

Couple of questions:

  1. Does your Library use CADisplayLink or?
  2. 60fps?
  3. Support for interactions while animation is happening?
  4. Could you talk a little about what drives the animation?

Thanks.

eonist commented 8 years ago

I first read about the implications of CADisplayLink here: https://blog.bigspaceship.com/the-holy-grail-of-ios-animation-intervals-e9e663ea93c4 Pretty good article. I recently implemented the CVDisplayLink which is the macOS equivalent.

RamonGilabert commented 8 years ago

Hey @eonist, thanks for the issue.

  1. & 4. The way Walker works is basically by taking the initial point and the final point and drawing the curve that the object should take, calculating all the points with a small step at the time, that way, a CAKeyframeAnimation is configured and will run the animation. The reason for that was for simplicity. I know there are some libraries that build the entire animation without using any sort of default API.
  2. For the question of the 60fps, the answer is I am not sure. The performance of it relies in CAKeyframeAnimation, so it should be 60fps, since the calculation in points shouldn't take that long and, when a curve that is not a spring is used, the calculation is much simpler.
  3. This is the reason why the library is in 0.10.0 and not in 1.0.0. I wanted to explore something different and not rely on CAKeyframeAnimation completely. Maybe build my own animation that moves ever x ms sending a notification or a delegate method – not sure. I haven't done much on it in a while, but I might definitely come back to it, this issue is mainly a motivation for it now – so thanks.

I'll read more about CADisplayLink, do you have a link to your macOS project? 😊

eonist commented 8 years ago

Thanks for the reply/answers!

I have a few blog posts about the AnimLib I've built for macOS:

http://stylekit.org/blog/2016/02/24/CVDisplayLink/ http://stylekit.org/blog/2016/02/20/Core-animation/ http://stylekit.org/blog/2016/03/09/Demo-app/

And here is the AnimLib (the important class being Animator.swift)

https://github.com/eonist/swift-utils/tree/master/misc/animation

In the example bellow, a clock pointer rotates 3 times:

let line:LineGraphic = addSubView(LineGraphic())
let animator = LoopingAnimator(Animation.sharedInstance,3,1,0,1,progress,Easing.easeLinear)
func progress(value:CGFloat){
   let angle = π * 2  * value
   line.p2 = line.p1.polarPoint(50,angle)
   line.draw()
}
animator.start()

The reason I asked about your lib was in terms of Interaction + animation which seems to be the tricky part. I want to attempt something similar for iOS, but looking through what other people has made first. Let me know if something is unclear with CADisplayLink. I'd be happy to help.

eonist commented 7 years ago

Hey, im lending som inspiration from your walker lib. Really liked the chaining you used. https://github.com/eonist/Element-iOS/wiki/anim-lib-ios