Skip to content

Commit

Permalink
Merge pull request #323 from ratmice/translate_scale_into_point
Browse files Browse the repository at this point in the history
Make TranslateScale::from_scale_about to take `Into<Point>`.
  • Loading branch information
richard-uk1 authored Feb 14, 2024
2 parents 223a487 + ecc5714 commit 4c48a13
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/translate_scale.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ impl TranslateScale {
/// assert_near(ts * Point::new(2., 2.), Point::new(3., 3.));
/// ```
#[inline]
pub fn from_scale_about(scale: f64, focus: Point) -> Self {
pub fn from_scale_about(scale: f64, focus: impl Into<Point>) -> Self {
// We need to create a transform that is equivalent to translating `focus`
// to the origin, followed by a normal scale, followed by reversing the translation.
// We need to find the (translation ∘ scale) that matches this.
let focus = focus.to_vec2();
let focus = focus.into().to_vec2();
let translation = focus - focus * scale;
Self::new(translation, scale)
}
Expand Down

0 comments on commit 4c48a13

Please sign in to comment.