blob: 97d95b6ee111ff3176a489415b5cf4213af9940b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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
}
}
|