pub struct AssFileOptions {}Implementations§
Source§impl AssFileOptions
impl AssFileOptions
Sourcepub fn get_ass_color(color: HexColor) -> String
pub fn get_ass_color(color: HexColor) -> String
Get BB:GG:RR representation of colors in Hexadecimal form
Examples found in repository?
examples/modify_existing_ass_file.rs (line 8)
4fn main() -> Result<(), std::io::Error>{
5 let mut ass_file = AssFile::from_file("./examples/subtitles.ass")?;
6 let dialogue = Dialogue::default()
7 .set_text("Hello Friend!");
8 let primary_color = AssFileOptions::get_ass_color(HexColor::RED);
9
10 ass_file.components.v4
11 .set_primarycolour(&primary_color);
12
13 ass_file.components.events
14 .add_dialogue(dialogue);
15
16 AssFile::save_file(&ass_file, "sub.ass");
17 println!("modified subtitles saved!");
18
19 Ok(())
20}More examples
examples/random_colors_from_subrip.rs (line 7)
6fn main() {
7 let hexcolor = AssFileOptions::get_ass_color(HexColor::YELLOW);
8 let srt_file = AssFile::from_srt("RapGod.srt");
9 let mut ass_file = AssFile::new();
10 let mut event = Events::default();
11
12 for srt_seg in srt_file.iter() {
13 let start = &srt_seg.start;
14 let end = &srt_seg.end;
15 let text = &srt_seg.text;
16
17 let random_color:HexColor = rand::random();
18
19 let dialogue = Dialogue::default()
20 .set_start(&start)
21 .set_end(&end)
22 .set_text(&text)
23 .set_colour(random_color);
24
25 event.add_dialogue(dialogue);
26 }
27
28
29 ass_file.components.script
30 .set_script(ScriptInfo::default());
31
32
33
34 ass_file.components.v4
35 .set_v4(V4Format::default())
36 .set_primarycolour(&hexcolor);
37 ass_file.components.events
38 .set_events(event);
39
40 AssFile::save_file(&ass_file, "new_subtitle.ass");
41}examples/timestamped_subtitles.rs (line 7)
5fn main() -> Result<(), IndexNotFound>{
6 let mut ass_file = AssFile::new();
7 let hexcolor = AssFileOptions::get_ass_color(HexColor::YELLOW);
8
9 let first_dialogue = Dialogue::default()
10 .set_start("0:00:00.10")
11 .set_end("0:00:00.50")
12 .set_text("Hello There.");
13
14 let second_dialogue = Dialogue::default()
15 .set_start("00:00.50")
16 .set_end("00:00.58")
17 .set_text("Hello Friend.");
18
19 let third_dialogue = Dialogue::default()
20 .set_start("0:00:00.58")
21 .set_end("0:00:01.01")
22 .set_text("Goodbye Friend.");
23
24 let events = Events::new()
25 .add_first_dialogue(first_dialogue)?
26 .add_dialogue(second_dialogue)
27 .add_dialogue(third_dialogue)
28 .create();
29
30
31 ass_file.components.script
32 .set_script(ScriptInfo::default())
33 .set_scripttype("FFMPEG");
34
35 ass_file.components.v4
36 .set_v4(V4Format::default())
37 .set_primarycolour(&hexcolor);
38
39 ass_file.components.events
40 .set_events(events);
41
42 AssFile::save_file(&ass_file, "new_subtitles.ass");
43
44 Ok(())
45
46}pub fn get_ass_color_text(color: HexColor) -> String
Auto Trait Implementations§
impl Freeze for AssFileOptions
impl RefUnwindSafe for AssFileOptions
impl Send for AssFileOptions
impl Sync for AssFileOptions
impl Unpin for AssFileOptions
impl UnwindSafe for AssFileOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more