about summary refs log tree commit diff
path: root/prism/src/rotate.rs
diff options
context:
space:
mode:
Diffstat (limited to 'prism/src/rotate.rs')
-rw-r--r--prism/src/rotate.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/prism/src/rotate.rs b/prism/src/rotate.rs
new file mode 100644
index 0000000..82f29d1
--- /dev/null
+++ b/prism/src/rotate.rs
@@ -0,0 +1,11 @@
+pub fn rotate_180<T: Copy>(data: &mut [T]) {
+	let mut rat = vec![data[0]; data.len()];
+
+	for (idx, px) in data.chunks(3).rev().enumerate() {
+		rat[idx * 3] = px[0];
+		rat[idx * 3 + 1] = px[1];
+		rat[idx * 3 + 2] = px[2];
+	}
+
+	data.copy_from_slice(&rat);
+}