benoitthore / KeyFrame

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Download

Introduction

The purpose of this library is to provide an easy way of building keyframe-based animations with a simple an intuitive DSL.

Install

Core: implementation 'com.benoitthore.keyframe:core:1.0.0'

Android: implementation 'com.benoitthore.keyframe:android:1.0.0'

Get started

Create a class

class CircleData(
    val x: MutableList<FrameProperty<Float>> = mutableListOf(),
    val y: MutableList<FrameProperty<Float>> = mutableListOf()
) : Normalizable {
    override val propertyList: List<MutableList<out FrameProperty<out Any>>> = listOf(x,y)
}

Create the frames

val frames = FrameAnimationBuilder.createNormalized<CircleData> {
        it.apply {
            frame {
                x set 0
                y set 0
            } 
            
            frame {
                x goto 10
                y goto 30
            } 

            frame {
                x goto 5
                y goto 5
            } 
        }
}

Get the animated value

val x = frame.x.animate(animationProgress)
val y = frame.y.animate(animationProgress)

Documentation

More info here

About


Languages

Language:Kotlin 100.0%