tiled_parser/
layer.rs

1use std::collections::HashMap;
2
3#[derive(Clone, Debug, Default, Deserialize, Serialize)]
4#[serde(default)]
5pub struct Layer {
6    pub name: String,
7    pub opacity: f32,
8    pub properties: Option<HashMap<String, String>>,
9    pub visible: bool,
10    pub width: u32,
11    pub height: u32,
12    pub x: f32,
13    pub y: f32,
14
15    #[serde(rename = "type")]
16    pub _type: String,
17
18    // for type = "tilelayer"
19    pub data: Vec<u32>,
20
21    // for type = "objectlayer"
22    pub draworder: String,
23    pub objects: Vec<Object>,
24}
25
26#[derive(Clone, Debug, Default, Deserialize, Serialize)]
27#[serde(default)]
28pub struct Object {
29    pub id: u32,
30    pub name: String,
31    
32    #[serde(rename = "type")]
33    pub _type: String,
34    pub gid: Option<u32>,
35    pub ellipse: Option<bool>,
36    pub polygon: Option<Vec<PolyPoint>>,
37    
38    pub properties: HashMap<String, String>,
39    pub rotation: f32,
40    pub visible: bool,
41    
42    pub height: f32,
43    pub width: f32,
44    
45    pub x: f32,
46    pub y: f32,
47}
48
49#[derive(Copy, Clone, Debug, Deserialize, Serialize)]
50pub struct PolyPoint {
51    pub x: f32,
52    pub y: f32,
53}