summaryrefslogtreecommitdiff
path: root/src/devices/screen/vector_points.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/screen/vector_points.rs')
-rw-r--r--src/devices/screen/vector_points.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/devices/screen/vector_points.rs b/src/devices/screen/vector_points.rs
new file mode 100644
index 0000000..97d95b6
--- /dev/null
+++ b/src/devices/screen/vector_points.rs
@@ -0,0 +1,28 @@
+use crate::*;
+
+pub struct VectorPoints {
+ points: [ScreenPosition; 3],
+ pointer: usize,
+}
+
+impl VectorPoints {
+ pub fn new() -> Self {
+ Self { points: [ScreenPosition::ZERO; 3], pointer: 0 }
+ }
+
+ pub fn push(&mut self, point: ScreenPosition) {
+ self.points[self.pointer] = point;
+ self.pointer = (self.pointer + 1) % 3;
+ }
+
+ pub fn get_pair(&self) -> [ScreenPosition; 2] {
+ [
+ self.points[(self.pointer + 1) % 3],
+ self.points[(self.pointer + 2) % 3],
+ ]
+ }
+
+ pub fn get_triple(&self) -> [ScreenPosition; 3] {
+ self.points
+ }
+}