From: Ian Jackson Date: Tue, 10 May 2022 20:11:04 +0000 (+0100) Subject: impl Mean for f64 X-Git-Tag: otter-1.1.0~238 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=afe06c86154ea77b61f9440b529f061cf04042e3;p=otter.git impl Mean for f64 We'll want this to calculate middles of SVGs. Signed-off-by: Ian Jackson --- 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 ----------