Skip to content

Commit

Permalink
Line::from for (Point, Point), (Point, Vec2) (#376)
Browse files Browse the repository at this point in the history
  • Loading branch information
waywardmonkeys authored Sep 11, 2024
1 parent 2cb3ec6 commit e34097b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ This release has an [MSRV][] of 1.65.
- Add `CircleSegment::inner_arc` and `CircleSegment::outer_arc` ([#368] by [@waywardmonkeys])
- Add `Rect::is_zero_area` and `Size::is_zero_area` and deprecate their `is_empty` methods. ([#370] by [@waywardmonkeys])
- Add `Line::reversed` and `Line::midpoint`. ([#375] by [@waywardmonkeys])
- Allow construction of `Line` from `(Point, Point)` and `(Point, Vec2)`. ([#376] by [@waywardmonkeys])

### Changed

Expand Down Expand Up @@ -69,6 +70,7 @@ Note: A changelog was not kept for or before this release
[#368]: https://github.com/linebender/kurbo/pull/368
[#370]: https://github.com/linebender/kurbo/pull/370
[#375]: https://github.com/linebender/kurbo/pull/375
[#376]: https://github.com/linebender/kurbo/pull/376

[Unreleased]: https://github.com/linebender/kurbo/compare/v0.11.0...HEAD
[0.11.0]: https://github.com/linebender/kurbo/releases/tag/v0.11.0
Expand Down
12 changes: 12 additions & 0 deletions src/line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,18 @@ impl Line {
}
}

impl From<(Point, Point)> for Line {
fn from((from, to): (Point, Point)) -> Self {
Line::new(from, to)
}
}

impl From<(Point, Vec2)> for Line {
fn from((origin, displacement): (Point, Vec2)) -> Self {
Line::new(origin, origin + displacement)
}
}

impl ParamCurve for Line {
#[inline]
fn eval(&self, t: f64) -> Point {
Expand Down

0 comments on commit e34097b

Please sign in to comment.