diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-03-19 22:28:49 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-03-19 22:39:19 +0100 |
| commit | ab43bd802eafe33977a91893907e67553e099569 (patch) | |
| tree | af4dead92b143348f52e2e8f869df3f7dfd7322a /src/geom | |
| parent | d6aaae0cea1e79eecd85dc94ab85b9ad8eff48e8 (diff) | |
Renaming and refactoring
Diffstat (limited to 'src/geom')
| -rw-r--r-- | src/geom/paint.rs | 14 | ||||
| -rw-r--r-- | src/geom/path.rs | 22 |
2 files changed, 18 insertions, 18 deletions
diff --git a/src/geom/paint.rs b/src/geom/paint.rs index c01b21da..eacd6f95 100644 --- a/src/geom/paint.rs +++ b/src/geom/paint.rs @@ -236,7 +236,7 @@ impl FromStr for RgbaColor { fn from_str(hex_str: &str) -> Result<Self, Self::Err> { let hex_str = hex_str.strip_prefix('#').unwrap_or(hex_str); if hex_str.chars().any(|c| !c.is_ascii_hexdigit()) { - return Err("string contains non-hexadecimal letters"); + return Err("color string contains non-hexadecimal letters"); } let len = hex_str.len(); @@ -244,7 +244,7 @@ impl FromStr for RgbaColor { let short = len == 3 || len == 4; let alpha = len == 4 || len == 8; if !long && !short { - return Err("string has wrong length"); + return Err("color string has wrong length"); } let mut values: [u8; 4] = [u8::MAX; 4]; @@ -406,10 +406,10 @@ mod tests { assert_eq!(RgbaColor::from_str(hex), Err(message)); } - test("a5", "string has wrong length"); - test("12345", "string has wrong length"); - test("f075ff011", "string has wrong length"); - test("hmmm", "string contains non-hexadecimal letters"); - test("14B2AH", "string contains non-hexadecimal letters"); + test("a5", "color string has wrong length"); + test("12345", "color string has wrong length"); + test("f075ff011", "color string has wrong length"); + test("hmmm", "color string contains non-hexadecimal letters"); + test("14B2AH", "color string contains non-hexadecimal letters"); } } diff --git a/src/geom/path.rs b/src/geom/path.rs index 3a7c3033..1c5325a3 100644 --- a/src/geom/path.rs +++ b/src/geom/path.rs @@ -2,11 +2,11 @@ use super::*; /// A bezier path. #[derive(Debug, Default, Clone, Eq, PartialEq, Hash)] -pub struct Path(pub Vec<PathElement>); +pub struct Path(pub Vec<PathItem>); -/// An element in a bezier path. +/// An item in a bezier path. #[derive(Debug, Clone, Eq, PartialEq, Hash)] -pub enum PathElement { +pub enum PathItem { MoveTo(Point), LineTo(Point), CubicTo(Point, Point, Point), @@ -32,23 +32,23 @@ impl Path { path } - /// Push a [`MoveTo`](PathElement::MoveTo) element. + /// Push a [`MoveTo`](PathItem::MoveTo) item. pub fn move_to(&mut self, p: Point) { - self.0.push(PathElement::MoveTo(p)); + self.0.push(PathItem::MoveTo(p)); } - /// Push a [`LineTo`](PathElement::LineTo) element. + /// Push a [`LineTo`](PathItem::LineTo) item. pub fn line_to(&mut self, p: Point) { - self.0.push(PathElement::LineTo(p)); + self.0.push(PathItem::LineTo(p)); } - /// Push a [`CubicTo`](PathElement::CubicTo) element. + /// Push a [`CubicTo`](PathItem::CubicTo) item. pub fn cubic_to(&mut self, p1: Point, p2: Point, p3: Point) { - self.0.push(PathElement::CubicTo(p1, p2, p3)); + self.0.push(PathItem::CubicTo(p1, p2, p3)); } - /// Push a [`ClosePath`](PathElement::ClosePath) element. + /// Push a [`ClosePath`](PathItem::ClosePath) item. pub fn close_path(&mut self) { - self.0.push(PathElement::ClosePath); + self.0.push(PathItem::ClosePath); } } |
