chiark
/
gitweb
/
~ianmdlvl
/
otter.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
7a721e4
)
impl Mean for f64
author
Ian Jackson
<ijackson@chiark.greenend.org.uk>
Tue, 10 May 2022 20:11:04 +0000
(21:11 +0100)
committer
Ian Jackson
<ijackson@chiark.greenend.org.uk>
Wed, 11 May 2022 23:19:17 +0000
(
00:19
+0100)
We'll want this to calculate middles of SVGs.
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
base/geometry.rs
patch
|
blob
|
history
diff --git
a/base/geometry.rs
b/base/geometry.rs
index 2733632ed09d420a2e8a60aa5d1943da1dcd4196..6983a3a0707d22f055ffaeec7f95c794d6e9a52f 100644
(file)
--- 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 ----------