diff --git a/crates/ec-ass/src/lib.rs b/crates/ec-ass/src/lib.rs index 070116ab..38e683a7 100644 --- a/crates/ec-ass/src/lib.rs +++ b/crates/ec-ass/src/lib.rs @@ -210,8 +210,10 @@ fn alignment(code: i32, v4: bool) -> TextAlign { } } +type Rgba = (u8, u8, u8, u8); + /// `&HAABBGGRR&`: BGR with a *transparency* byte, so 0 is opaque. -fn parse_color(value: &str) -> Option<(u8, u8, u8, u8)> { +fn parse_color(value: &str) -> Option { let digits: String = value .trim() .trim_start_matches(['&', 'H', 'h']) diff --git a/crates/ec-subs/src/ir.rs b/crates/ec-subs/src/ir.rs index f71ee609..91360ba1 100644 --- a/crates/ec-subs/src/ir.rs +++ b/crates/ec-subs/src/ir.rs @@ -7,6 +7,8 @@ //! ASS `\pos` and `\an` — rides beside the runs instead of inside them, because //! it applies to the cue as a whole. +pub type Rgb = (u8, u8, u8); + /// How a karaoke syllable is highlighted, after libass. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] pub enum KaraokeMode { @@ -38,7 +40,7 @@ pub enum Segment { /// Children in an explicit colour (``, ASS `\c` / `\1c`). Color { /// Text colour, one byte per channel. - rgb: (u8, u8, u8), + rgb: Rgb, /// What the colour applies to. children: Vec, }, diff --git a/crates/ec-subs/src/markup.rs b/crates/ec-subs/src/markup.rs index 02d355e2..22032969 100644 --- a/crates/ec-subs/src/markup.rs +++ b/crates/ec-subs/src/markup.rs @@ -8,7 +8,7 @@ //! with nothing open is dropped, and a `<` that begins no tag at all is the //! character it looks like. -use crate::ir::Segment; +use crate::ir::{Rgb, Segment}; /// Bytes to text, the way a subtitle file has to be read: a UTF-8 or UTF-16 BOM /// consumed, invalid sequences replaced rather than refused, and CRLF (or a @@ -301,7 +301,7 @@ fn attribute(attrs: &str, name: &str) -> Option { } /// `#rrggbb`, `#rgb`, or one of the sixteen names HTML has always had. -fn parse_color(value: &str) -> Option<(u8, u8, u8)> { +fn parse_color(value: &str) -> Option { let value = value.trim(); if let Some(hex) = value.strip_prefix('#') { let digits: String = hex.chars().take_while(char::is_ascii_hexdigit).collect();