Skip to content

Commit 026652e

Browse files
committed
styling done
1 parent 6efeaad commit 026652e

File tree

1 file changed

+66
-10
lines changed

1 file changed

+66
-10
lines changed

generate/src/bin/generate_sample_videos.rs

+66-10
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ use compositor_render::{event_handler::subscribe, Resolution};
1010
use generate::compositor_instance::CompositorInstance;
1111
use serde_json::json;
1212

13+
struct SceneStyle {
14+
timer_font_size: u32,
15+
timer_bottom: u32,
16+
timer_right: u32,
17+
title_font_size: u32,
18+
}
19+
1320
fn main() {
1421
let _ = fs::remove_dir_all(workingdir());
1522
fs::create_dir_all(workingdir()).unwrap();
@@ -21,6 +28,12 @@ fn main() {
2128
height: 1080,
2229
},
2330
"1920x1080",
31+
SceneStyle {
32+
timer_font_size: 90,
33+
timer_bottom: 100,
34+
timer_right: 100,
35+
title_font_size: 250,
36+
},
2437
);
2538

2639
generate_video_series(
@@ -30,6 +43,12 @@ fn main() {
3043
height: 1920,
3144
},
3245
"1080x1920",
46+
SceneStyle {
47+
timer_font_size: 90,
48+
timer_bottom: 100,
49+
timer_right: 100,
50+
title_font_size: 250,
51+
},
3352
);
3453

3554
generate_video_series(
@@ -39,6 +58,12 @@ fn main() {
3958
height: 480,
4059
},
4160
"854x480",
61+
SceneStyle {
62+
timer_font_size: 45,
63+
timer_bottom: 50,
64+
timer_right: 50,
65+
title_font_size: 125,
66+
},
4267
);
4368

4469
generate_video_series(
@@ -48,6 +73,12 @@ fn main() {
4873
height: 854,
4974
},
5075
"480x854",
76+
SceneStyle {
77+
timer_font_size: 45,
78+
timer_bottom: 50,
79+
timer_right: 50,
80+
title_font_size: 125,
81+
},
5182
);
5283

5384
generate_video_series(
@@ -57,6 +88,12 @@ fn main() {
5788
height: 1080,
5889
},
5990
"1440x1080",
91+
SceneStyle {
92+
timer_font_size: 90,
93+
timer_bottom: 100,
94+
timer_right: 100,
95+
title_font_size: 250,
96+
},
6097
);
6198

6299
generate_video_series(
@@ -66,17 +103,29 @@ fn main() {
66103
height: 1440,
67104
},
68105
"1080x1440",
106+
SceneStyle {
107+
timer_font_size: 90,
108+
timer_bottom: 100,
109+
timer_right: 100,
110+
title_font_size: 250,
111+
},
69112
);
70113
}
71114

72-
fn generate_video_series(duration: Duration, resolution: Resolution, name_suffix: &str) {
115+
fn generate_video_series(
116+
duration: Duration,
117+
resolution: Resolution,
118+
name_suffix: &str,
119+
scene_style: SceneStyle,
120+
) {
73121
// HSV 240°, 50%, 65% (dark blue)
74122
generate_video(
75123
workingdir().join(format!("input_1_{}.mp4", name_suffix)),
76124
"Input 1",
77125
"#5353a6ff",
78126
duration,
79127
&resolution,
128+
&scene_style,
80129
)
81130
.unwrap();
82131
// HSV 120°, 50%, 65% (green)
@@ -86,6 +135,7 @@ fn generate_video_series(duration: Duration, resolution: Resolution, name_suffix
86135
"#53a653ff",
87136
duration,
88137
&resolution,
138+
&scene_style,
89139
)
90140
.unwrap();
91141
// HSV 0°, 50%, 65% (red)
@@ -95,6 +145,7 @@ fn generate_video_series(duration: Duration, resolution: Resolution, name_suffix
95145
"#a65353ff",
96146
duration,
97147
&resolution,
148+
&scene_style,
98149
)
99150
.unwrap();
100151
// HSV 60°, 50%, 65% (yellow)
@@ -104,6 +155,7 @@ fn generate_video_series(duration: Duration, resolution: Resolution, name_suffix
104155
"#a6a653ff",
105156
duration,
106157
&resolution,
158+
&scene_style,
107159
)
108160
.unwrap();
109161
// HSV 180°, 50%, 65% (light blue)
@@ -113,6 +165,7 @@ fn generate_video_series(duration: Duration, resolution: Resolution, name_suffix
113165
"#53a6a6ff",
114166
duration,
115167
&resolution,
168+
&scene_style,
116169
)
117170
.unwrap();
118171
// HSV 300°, 50%, 65% (purple)
@@ -122,6 +175,7 @@ fn generate_video_series(duration: Duration, resolution: Resolution, name_suffix
122175
"#a653a6ff",
123176
duration,
124177
&resolution,
178+
&scene_style,
125179
)
126180
.unwrap();
127181
}
@@ -138,6 +192,7 @@ fn generate_video(
138192
rgba_color: &str,
139193
duration: Duration,
140194
resolution: &Resolution,
195+
scene_style: &SceneStyle,
141196
) -> Result<()> {
142197
let instance = CompositorInstance::start();
143198

@@ -158,7 +213,7 @@ fn generate_video(
158213
"crf": "32"
159214
}
160215
},
161-
"initial": scene(text, rgba_color, resolution, Duration::ZERO)
216+
"initial": scene(text, rgba_color, resolution, Duration::ZERO, scene_style)
162217
},
163218
}),
164219
)?;
@@ -176,7 +231,7 @@ fn generate_video(
176231
instance.send_request(
177232
"output/output_1/update",
178233
json!({
179-
"video": scene(text, rgba_color, resolution, pts),
234+
"video": scene(text, rgba_color, resolution, pts, scene_style),
180235
"schedule_time_ms": pts.as_millis(),
181236
}),
182237
)?;
@@ -205,6 +260,7 @@ fn scene(
205260
rgba_color: &str,
206261
resolution: &Resolution,
207262
pts: Duration,
263+
style: &SceneStyle,
208264
) -> serde_json::Value {
209265
json!({
210266
"root": {
@@ -216,24 +272,24 @@ fn scene(
216272
{
217273
"type": "text",
218274
"text": text,
219-
"font_size": resolution.width / 8,
275+
"font_size": style.title_font_size,
220276
"width": resolution.width,
221277
"align": "center",
222278
"font_family": "Comic Sans MS",
223279
},
224280
{ "type": "view" },
225281
{
226282
"type": "view",
227-
"bottom": resolution.height / 6,
228-
"right": resolution.width / 8,
229-
"width": resolution.width / 6,
230-
"height": resolution.height / 6,
283+
"bottom": style.timer_bottom,
284+
"right": style.timer_right,
285+
"width": resolution.width / 2,
286+
"height": style.timer_font_size,
231287
"children": [
232288
{
233289
"type": "text",
234290
"text": format!("{:.2}s", pts.as_millis() as f32 / 1000.0),
235-
"font_size": resolution.width / 16,
236-
"width": resolution.width / 6,
291+
"font_size": style.timer_font_size,
292+
"width": resolution.width / 2,
237293
"align": "right",
238294
"font_family": "Comic Sans MS",
239295
},

0 commit comments

Comments
 (0)