commonMain.ru.casperix.spine.animation.ShearTimeline.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 ShearTimeline(
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.isActive) {
val x = FrameCalculator.getRelativeValue(xFrames, time, weight, blend, bone.local.shearX, bone.data.local.shearX, false)
val y = FrameCalculator.getRelativeValue(yFrames, time, weight, blend, bone.local.shearY, bone.data.local.shearY, false)
bone.local = bone.local.copy(shearX = x, shearY = y)
}
}
}