swf_types/
basic_types.rs

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