tee_morphosis 1.3.1

Lib for parsing, splitting and building tee
Documentation
//! # UV mapping module

pub type ContentSize = (u32, u32);

pub const BODY_SIZE: ContentSize = (96, 96);
pub const FEET_SIZE: ContentSize = (64, 32);
pub const EYE_SIZE: ContentSize = (32, 32);
pub const HAND_SIZE: ContentSize = (32, 32);

#[derive(Debug, Clone, Copy, PartialEq)]
pub struct UVPart {
    pub x: u32,
    pub y: u32,
    pub w: u32,
    pub h: u32,
}

#[derive(Debug, Clone, Copy, PartialEq)]
/// Mappings for parsing
pub struct UV {
    pub body: UVPart,
    pub body_shadow: UVPart,
    pub feet: UVPart,
    pub feet_shadow: UVPart,
    pub hand: UVPart,
    pub hand_shadow: UVPart,
    /// [Normal, Angry, Pain, Happy, Empty, Surprise]
    pub eyes: [UVPart; 6],
    pub container: ContentSize,
}

/// Describe position and size of each part of Tee on the image (256x128).
pub const TEE_UV_LAYOUT: UV = {
    const BODY_END_X: u32 = BODY_SIZE.0;
    const HANDS_AND_FEET_START_X: u32 = BODY_SIZE.0 * 2;
    const HAND_SHADOW_START_X: u32 = HANDS_AND_FEET_START_X + HAND_SIZE.0;
    const FEET_START_Y: u32 = HAND_SIZE.1;
    const FEET_SHADOW_START_Y: u32 = FEET_START_Y + FEET_SIZE.1;
    const EYES_START_X: u32 = 64;
    const EYES_START_Y: u32 = BODY_SIZE.1;

    UV {
        container: (256, 128),
        body: UVPart {
            x: 0,
            y: 0,
            w: BODY_SIZE.0,
            h: BODY_SIZE.1,
        },
        body_shadow: UVPart {
            x: BODY_END_X,
            y: 0,
            w: BODY_SIZE.0,
            h: BODY_SIZE.1,
        },
        feet: UVPart {
            x: HANDS_AND_FEET_START_X,
            y: FEET_START_Y,
            w: FEET_SIZE.0,
            h: FEET_SIZE.1,
        },
        feet_shadow: UVPart {
            x: HANDS_AND_FEET_START_X,
            y: FEET_SHADOW_START_Y,
            w: FEET_SIZE.0,
            h: FEET_SIZE.1,
        },
        hand: UVPart {
            x: HANDS_AND_FEET_START_X,
            y: 0,
            w: HAND_SIZE.0,
            h: HAND_SIZE.1,
        },
        hand_shadow: UVPart {
            x: HAND_SHADOW_START_X,
            y: 0,
            w: HAND_SIZE.0,
            h: HAND_SIZE.1,
        },
        eyes: [
            UVPart {
                x: EYES_START_X,
                y: EYES_START_Y,
                w: EYE_SIZE.0,
                h: EYE_SIZE.1,
            }, // Normal
            UVPart {
                x: EYES_START_X + EYE_SIZE.0,
                y: EYES_START_Y,
                w: EYE_SIZE.0,
                h: EYE_SIZE.1,
            }, // Angry
            UVPart {
                x: EYES_START_X + EYE_SIZE.0 * 2,
                y: EYES_START_Y,
                w: EYE_SIZE.0,
                h: EYE_SIZE.1,
            }, // Pain
            UVPart {
                x: EYES_START_X + EYE_SIZE.0 * 3,
                y: EYES_START_Y,
                w: EYE_SIZE.0,
                h: EYE_SIZE.1,
            }, // Happy
            UVPart {
                x: EYES_START_X + EYE_SIZE.0 * 4,
                y: EYES_START_Y,
                w: EYE_SIZE.0,
                h: EYE_SIZE.1,
            }, // Empty
            UVPart {
                x: EYES_START_X + EYE_SIZE.0 * 5,
                y: EYES_START_Y,
                w: EYE_SIZE.0,
                h: EYE_SIZE.1,
            }, // Surprise
        ],
    }
};