commonMain.ru.casperix.spine.animation.ScaleTimeline.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spine-jvm Show documentation
Show all versions of spine-jvm Show documentation
Signals for all occasions
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)
}
}
}