commonMain.ru.casperix.spine.Attachment.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
import ru.casperix.math.color.Color
import ru.casperix.math.Transform
import ru.casperix.spine.device.PixelMapRegion
interface Attachment {
val name: String
}
class UnknownAttachment(override val name: String) : Attachment
class Sequence
interface HasTextureRegion {
val color: Color
val path: String?
val region: PixelMapRegion
val sequence: Sequence?
}
class RegionAttachment(
override val name: String,
override val color: Color,
override val path: String?,
override val sequence: Sequence?,
override val region: PixelMapRegion,
val x: Float,
val y: Float,
val scaleX: Float,
val scaleY: Float,
val rotation: Float,
val width: Float,
val height: Float,
val offset: FloatArray,
val uvs: FloatArray,
// val regionHeight:Float,
// val regionOffsetX:Float,
// val regionOffsetY:Float,
// val regionOriginalHeight:Float,
// val regionOriginalWidth:Float,
// val regionWidth:Float,
// val rendererObject:Any,
) : Attachment, HasTextureRegion {
val regionScaleX = width / region.attributes.bounds.dimension.x
val regionScaleY = height / region.attributes.bounds.dimension.y
val transform get() = Transform(x, y, rotation, scaleX * regionScaleX, scaleY * regionScaleY, 0f, 0f)
}
class BoundingBoxAttachment(
val color: Color,
name: String,
bones: IntArray,
id: Int,
timelineAttachment: Attachment,
vertices: FloatArray,
worldVerticesLength: Int,
) : VertexAttachment(name, bones, id, timelineAttachment, vertices, worldVerticesLength) {
}
open class VertexAttachment(
override val name: String,
val bones: IntArray,
val id: Int,
val timelineAttachment: Attachment,
val vertices: FloatArray,
val worldVerticesLength: Int,
) : Attachment