From afe06c86154ea77b61f9440b529f061cf04042e3 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 10 May 2022 21:11:04 +0100 Subject: [PATCH] impl Mean for f64 We'll want this to calculate middles of SVGs. Signed-off-by: Ian Jackson --- base/geometry.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/base/geometry.rs b/base/geometry.rs index 2733632e..6983a3a0 100644 --- a/base/geometry.rs +++ b/base/geometry.rs @@ -85,6 +85,9 @@ pub trait Mean { fn mean(&self, other: &Self) -> Self; } impl Mean for i32 { fn mean(&self, other: &Self) -> Self { ((*self as i64 + *other as i64) / 2) as i32 } } +impl Mean for f64 { fn mean(&self, other: &Self) -> Self { + self * 0.5 + other * 0.5 +} } //---------- Pos ---------- -- 2.30.2