All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.ru.casperix.spine.animation.ScaleTimeline.kt Maven / Gradle / Ivy

There is a newer version: 0.9.0
Show newest version
package ru.casperix.spine.animation

class ScaleTimeline(
    override val boneIndex: Int,
    override val frames: List,
) : AbstractTimeline(frames), CurveTimeline1, BoneTimeline {
    val xFrames = frames.map { createFrame(it.time, it.x, it.curve, 0) }
    val yFrames = frames.map { createFrame(it.time, it.y, it.curve, 1) }

    override fun apply(context: AnimationContext) = context.run {
        val bone = skeleton.bones[boneIndex]
        if (bone.data.name != "head") return@run

        if (bone.isActive) {
            val x = FrameCalculator.getRelativeValue(xFrames, time, weight, blend, bone.local.scaleX, bone.data.local.scaleX, true)
            val y = FrameCalculator.getRelativeValue(yFrames, time, weight, blend, bone.local.scaleY, bone.data.local.scaleY, true)
            bone.local = bone.local.copy(scaleX = x, scaleY = y)
        }
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy