summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2019-11-05 03:16:46 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2019-11-05 03:16:46 +0100
commit470266f54069a1c9b6147026d018b437b6457f7b (patch)
tree44778d322a6b95ab518fd8e9c89926390acb4380 /core
parentba470a2b2a334fa961af19ef9412ad2dfb4acbeb (diff)
downloadiced-470266f54069a1c9b6147026d018b437b6457f7b.tar.gz
iced-470266f54069a1c9b6147026d018b437b6457f7b.tar.bz2
iced-470266f54069a1c9b6147026d018b437b6457f7b.zip
Add horizontal offset to `Primitive::Clip`
Diffstat (limited to 'core')
-rw-r--r--core/src/vector.rs21
1 files changed, 16 insertions, 5 deletions
diff --git a/core/src/vector.rs b/core/src/vector.rs
index f45daab9..92bf64ff 100644
--- a/core/src/vector.rs
+++ b/core/src/vector.rs
@@ -1,15 +1,26 @@
/// A 2D vector.
#[derive(Debug, Clone, Copy, PartialEq)]
-pub struct Vector {
- pub x: f32,
- pub y: f32,
+pub struct Vector<T = f32> {
+ pub x: T,
+ pub y: T,
}
-impl Vector {
+impl<T> Vector<T> {
/// Creates a new [`Vector`] with the given components.
///
/// [`Vector`]: struct.Vector.html
- pub fn new(x: f32, y: f32) -> Self {
+ pub fn new(x: T, y: T) -> Self {
Self { x, y }
}
}
+
+impl<T> std::ops::Add for Vector<T>
+where
+ T: std::ops::Add<Output = T>,
+{
+ type Output = Self;
+
+ fn add(self, b: Self) -> Self {
+ Self::new(self.x + b.x, self.y + b.y)
+ }
+}