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

commonMain.com.littlekt.file.atlas.AtlasInfo.kt Maven / Gradle / Ivy

There is a newer version: 0.11.0
Show newest version
package com.littlekt.file.atlas

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

/**
 * @author Colton Daily
 * @date 11/27/2021
 */
internal data class AtlasInfo(val meta: AtlasPage.Meta, val pages: List) {
    val frames = pages.flatMap { it.frames }
    val framesMap = frames.associateBy { it.name }
}

@Serializable
internal data class AtlasPage(
    val meta: Meta,
    var filterMin: Boolean = false,
    var filterMag: Boolean = false,
    var repeatX: Boolean = false,
    var repeatY: Boolean = false,
    val frames: List
) {
    @Serializable
    internal data class Frame(
        @SerialName("filename") val name: String,
        val frame: Rect,
        val rotated: Boolean,
        val trimmed: Boolean,
        val spriteSourceSize: Rect,
        val sourceSize: Size
    )

    @Serializable internal data class Rect(val x: Int, val y: Int, val w: Int, val h: Int)

    @Serializable internal data class Size(val w: Int, val h: Int)

    @Serializable
    internal data class Meta(
        val app: String = "",
        val version: String = "1.0.0",
        val image: String = "",
        val format: String = "",
        val scale: Float = 1f,
        val size: Size = Size(0, 0),
        val frameTags: List = listOf(),
        val layers: List = listOf(),
        val slices: List = listOf(),
        @SerialName("related_multi_packs") val relatedMultiPacks: List = listOf()
    )

    @Serializable
    internal data class FrameTag(
        val name: String,
        val from: Int,
        val to: Int,
        val direction: String
    )

    @Serializable
    internal data class Layer(val name: String, val opacity: Int, val blendMode: String)

    @Serializable
    internal data class Slice(val name: String, val color: String, val key: List)

    @Serializable internal data class Key(val frame: Int, val bound: Rect)
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy