1use serde::{Deserialize, Serialize};
4use std::collections::HashMap;
5
6#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8pub struct MilkPreset {
9 pub version: u32,
11
12 pub ps_version_warp: u32,
14
15 pub ps_version_comp: u32,
17
18 pub parameters: PresetParameters,
20
21 pub per_frame_equations: Vec<String>,
23
24 pub per_pixel_equations: Vec<String>,
26
27 pub per_frame_init_equations: Vec<String>,
29
30 pub waves: Vec<WaveCode>,
32
33 pub shapes: Vec<ShapeCode>,
35
36 pub warp_shader: Option<String>,
38
39 pub comp_shader: Option<String>,
41}
42
43#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
45pub struct PresetParameters {
46 pub f_rating: f32,
48 pub f_gamma_adj: f32,
49 pub f_decay: f32,
50 pub f_video_echo_zoom: f32,
51 pub f_video_echo_alpha: f32,
52 pub n_video_echo_orientation: i32,
53
54 pub n_wave_mode: i32,
56 pub b_additive_waves: bool,
57 pub b_wave_dots: bool,
58 pub b_wave_thick: bool,
59 pub b_mod_wave_alpha_by_volume: bool,
60 pub b_maximize_wave_color: bool,
61 pub f_wave_alpha: f32,
62 pub f_wave_scale: f32,
63 pub f_wave_smoothing: f32,
64 pub f_wave_param: f32,
65 pub f_mod_wave_alpha_start: f32,
66 pub f_mod_wave_alpha_end: f32,
67
68 pub b_tex_wrap: bool,
70 pub b_darken_center: bool,
71 pub b_red_blue_stereo: bool,
72 pub b_brighten: bool,
73 pub b_darken: bool,
74 pub b_solarize: bool,
75 pub b_invert: bool,
76
77 pub f_warp_anim_speed: f32,
79 pub f_warp_scale: f32,
80 pub f_zoom_exponent: f32,
81 pub f_shader: f32,
82
83 pub zoom: f32,
85 pub rot: f32,
86 pub cx: f32,
87 pub cy: f32,
88 pub dx: f32,
89 pub dy: f32,
90 pub warp: f32,
91 pub sx: f32,
92 pub sy: f32,
93
94 pub wave_r: f32,
96 pub wave_g: f32,
97 pub wave_b: f32,
98 pub wave_x: f32,
99 pub wave_y: f32,
100
101 pub ob_size: f32,
103 pub ob_r: f32,
104 pub ob_g: f32,
105 pub ob_b: f32,
106 pub ob_a: f32,
107
108 pub ib_size: f32,
110 pub ib_r: f32,
111 pub ib_g: f32,
112 pub ib_b: f32,
113 pub ib_a: f32,
114
115 pub n_motion_vectors_x: f32,
117 pub n_motion_vectors_y: f32,
118 pub mv_dx: f32,
119 pub mv_dy: f32,
120 pub mv_l: f32,
121 pub mv_r: f32,
122 pub mv_g: f32,
123 pub mv_b: f32,
124 pub mv_a: f32,
125
126 pub b1n: f32,
128 pub b2n: f32,
129 pub b3n: f32,
130 pub b1x: f32,
131 pub b2x: f32,
132 pub b3x: f32,
133 pub b1ed: f32,
134
135 pub extra: HashMap<String, String>,
137}
138
139impl PresetParameters {
140 pub fn zoomexp(&self) -> f32 {
142 self.f_zoom_exponent
143 }
144 pub fn decay(&self) -> f32 {
145 self.f_decay
146 }
147 pub fn gamma(&self) -> f32 {
148 self.f_gamma_adj
149 }
150 pub fn echo_zoom(&self) -> f32 {
151 self.f_video_echo_zoom
152 }
153 pub fn echo_alpha(&self) -> f32 {
154 self.f_video_echo_alpha
155 }
156 pub fn wave_mode(&self) -> i32 {
157 self.n_wave_mode
158 }
159 pub fn wave_a(&self) -> f32 {
160 self.f_wave_alpha
161 }
162 pub fn darken_center(&self) -> bool {
163 self.b_darken_center
164 }
165 pub fn wrap(&self) -> bool {
166 self.b_tex_wrap
167 }
168 pub fn invert(&self) -> bool {
169 self.b_invert
170 }
171 pub fn brighten(&self) -> bool {
172 self.b_brighten
173 }
174 pub fn darken(&self) -> bool {
175 self.b_darken
176 }
177 pub fn solarize(&self) -> bool {
178 self.b_solarize
179 }
180}
181
182#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
184pub struct WaveCode {
185 pub index: usize,
186 pub enabled: bool,
187 pub samples: i32,
188 pub sep: i32,
189 pub b_spectrum: bool,
190 pub b_use_dots: bool,
191 pub b_draw_thick: bool,
192 pub b_additive: bool,
193 pub scaling: f32,
194 pub smoothing: f32,
195 pub r: f32,
196 pub g: f32,
197 pub b: f32,
198 pub a: f32,
199
200 pub per_frame_equations: Vec<String>,
202
203 pub per_point_equations: Vec<String>,
205
206 pub per_frame_init_equations: Vec<String>,
208}
209
210#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
212pub struct ShapeCode {
213 pub index: usize,
214 pub enabled: bool,
215 pub sides: i32,
216 pub additive: bool,
217 pub thick_outline: bool,
218 pub textured: bool,
219 pub num_inst: i32,
220 pub x: f32,
221 pub y: f32,
222 pub rad: f32,
223 pub ang: f32,
224 pub tex_ang: f32,
225 pub tex_zoom: f32,
226 pub r: f32,
227 pub g: f32,
228 pub b: f32,
229 pub a: f32,
230 pub r2: f32,
231 pub g2: f32,
232 pub b2: f32,
233 pub a2: f32,
234 pub border_r: f32,
235 pub border_g: f32,
236 pub border_b: f32,
237 pub border_a: f32,
238
239 pub per_frame_equations: Vec<String>,
241
242 pub per_frame_init_equations: Vec<String>,
244}
245
246impl Default for MilkPreset {
247 fn default() -> Self {
248 Self {
249 version: 201,
250 ps_version_warp: 2,
251 ps_version_comp: 2,
252 parameters: PresetParameters::default(),
253 per_frame_equations: Vec::new(),
254 per_pixel_equations: Vec::new(),
255 per_frame_init_equations: Vec::new(),
256 waves: Vec::new(),
257 shapes: Vec::new(),
258 warp_shader: None,
259 comp_shader: None,
260 }
261 }
262}