Coder Social home page Coder Social logo

bezierPath? about kinetic HOT 4 OPEN

markuswinkler avatar markuswinkler commented on July 20, 2024
bezierPath?

from kinetic.

Comments (4)

u10int avatar u10int commented on July 20, 2024 1

I'm finally close to having all of the refactoring of the library done for the 1.0 release over in the https://github.com/u10int/Kinetic/tree/props-refactor branch. I also just added support for animating along both quadratic and cubic bezier paths:

let path = QuadBezier(start: start.center, cp1: controlPoint1.center, end: end.center)
let tween = Kinetic.animate(square).along(path).duration(1).ease(.quartInOut)

Aside from some additional final cleanup of the code and API and a few bugs, thinking this branch is pretty close to being production-ready for updating master with. Feel free to test it out and let me know if you find any issues.

from kinetic.

u10int avatar u10int commented on July 20, 2024

This isn't possible with the library yet, but it is next on my list of things to add. Once I get the refactoring branch merged into master, the library will be at a more stable 1.0 version and then I'll be working on support for bezier path animations.

Hopefully I can get the refactor merged into master in the coming weeks. Until then, here's the branch that contains the newer API for the library: https://github.com/u10int/Kinetic/tree/props-refactor

from kinetic.

markuswinkler avatar markuswinkler commented on July 20, 2024

Cool! :)

I solved the bezier path.
I wanted an icon to move along a path while getting smaller and fade out towards the end.

func QuadBezier(t:CGFloat, start:CGFloat, c1:CGFloat, end:CGFloat) -> CGFloat
{
    let t_:CGFloat = (1.0 - t)
    let tt_:CGFloat = t_ * t_
    let tt:CGFloat = t * t

    return start * tt_ + 2.0 *  c1 * t_ * t + end * tt
}
let A = CGPoint(x: frame.origin.x, y: frame.origin.y)
let B = CGPoint(x: System.width-40, y: 32)
let C = CGPoint(x: A.x + (B.x - A.x)/2 - 40, y: -130)
let duration = 0.8
Kinetic.animate(icon).to(.alpha(0), .scale(0.5)).duration(0.08).delay(duration - 0.08).play()
Kinetic.animate(icon).to(.scale(0.3)).duration(duration).ease(Easing.inSine).play().onUpdate({ anim in
    let x = self.QuadBezier(t: CGFloat(anim.progress()), start: A.x, c1: C.x, end: B.x)
    let y = self.QuadBezier(t: CGFloat(anim.progress()), start: A.y, c1: C.y, end: B.y)
    icon.frame = CGRect(origin: CGPoint(x: x, y: y), size: icon.frame.size)
}).onComplete({ anim in
    icon.removeFromSuperview()
})

from kinetic.

markuswinkler avatar markuswinkler commented on July 20, 2024

great! very cool :)

from kinetic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.