swf_tree/
basic_types.rs

1use ::serde::{Deserialize, Serialize};
2use ::swf_fixed::{Sfixed16P16, Sfixed8P8};
3
4#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
5#[serde(rename_all = "snake_case")]
6pub struct ColorTransform {
7  pub red_mult: Sfixed8P8,
8  pub green_mult: Sfixed8P8,
9  pub blue_mult: Sfixed8P8,
10  pub red_add: i16,
11  pub green_add: i16,
12  pub blue_add: i16,
13}
14
15impl ::std::default::Default for ColorTransform {
16  fn default() -> Self {
17    Self {
18      red_mult: Sfixed8P8::from_value(1.0),
19      green_mult: Sfixed8P8::from_value(1.0),
20      blue_mult: Sfixed8P8::from_value(1.0),
21      red_add: 0,
22      green_add: 0,
23      blue_add: 0,
24    }
25  }
26}
27
28#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
29#[serde(rename_all = "snake_case")]
30pub struct ColorTransformWithAlpha {
31  pub red_mult: Sfixed8P8,
32  pub green_mult: Sfixed8P8,
33  pub blue_mult: Sfixed8P8,
34  pub alpha_mult: Sfixed8P8,
35  pub red_add: i16,
36  pub green_add: i16,
37  pub blue_add: i16,
38  pub alpha_add: i16,
39}
40
41impl ::std::default::Default for ColorTransformWithAlpha {
42  fn default() -> Self {
43    Self {
44      red_mult: Sfixed8P8::from_value(1.0),
45      green_mult: Sfixed8P8::from_value(1.0),
46      blue_mult: Sfixed8P8::from_value(1.0),
47      alpha_mult: Sfixed8P8::from_value(1.0),
48      red_add: 0,
49      green_add: 0,
50      blue_add: 0,
51      alpha_add: 0,
52    }
53  }
54}
55
56#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
57#[serde(rename_all = "kebab-case")]
58pub enum LanguageCode {
59  Auto,
60  Latin,
61  Japanese,
62  Korean,
63  SimplifiedChinese,
64  TraditionalChinese,
65}
66
67#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
68#[serde(rename_all = "snake_case")]
69pub struct Matrix {
70  pub scale_x: Sfixed16P16,
71  pub scale_y: Sfixed16P16,
72  pub rotate_skew0: Sfixed16P16,
73  pub rotate_skew1: Sfixed16P16,
74  pub translate_x: i32,
75  pub translate_y: i32,
76}
77
78impl ::std::default::Default for Matrix {
79  fn default() -> Self {
80    Self {
81      scale_x: Sfixed16P16::from_value(1.0),
82      scale_y: Sfixed16P16::from_value(1.0),
83      rotate_skew0: Sfixed16P16::from_value(0.0),
84      rotate_skew1: Sfixed16P16::from_value(0.0),
85      translate_x: 0,
86      translate_y: 0,
87    }
88  }
89}
90
91#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
92#[serde(rename_all = "snake_case")]
93pub struct NamedId {
94  pub id: u16,
95  pub name: String,
96}
97
98#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
99#[serde(rename_all = "snake_case")]
100pub struct Rect {
101  pub x_min: i32,
102  pub x_max: i32,
103  pub y_min: i32,
104  pub y_max: i32,
105}
106
107// Color point in the sRGB color space with 8-bit color depth
108#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
109#[serde(rename_all = "snake_case")]
110pub struct SRgb8 {
111  pub r: u8,
112  pub g: u8,
113  pub b: u8,
114}
115
116// Color point with straight alpha in the sRGB color space with 8-bit color depth
117#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
118#[serde(rename_all = "snake_case")]
119pub struct StraightSRgba8 {
120  pub r: u8,
121  pub g: u8,
122  pub b: u8,
123  pub a: u8,
124}
125
126#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
127#[serde(rename_all = "snake_case")]
128pub struct Vector2D {
129  pub x: i32,
130  pub y: i32,
131}