From 9690084c2859b13c5f05d117c8847586f79358e9 Mon Sep 17 00:00:00 2001
From: Erin <sylphofelectricity@gmail.com>
Date: Tue, 15 Aug 2017 15:34:20 -0500
Subject: [PATCH] textium::texture: implement a rotated patch method for the
 packer

---
 textium/src/texture.rs | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/textium/src/texture.rs b/textium/src/texture.rs
index 8271c72..8ede56d 100644
--- a/textium/src/texture.rs
+++ b/textium/src/texture.rs
@@ -30,6 +30,22 @@ pub trait Buffer2d: Sized {
             }
         }
     }
+
+    fn patch_rotated<B>(&mut self, x: usize, y: usize, buf: &B)
+        where B: Buffer2d<Pixel=Self::Pixel>
+    {
+        let (w, h) = buf.dimensions();
+
+        // TODO: can this be optimized by performing an unsafe memcpy of some sort?
+        for sy in 0..h {
+            for sx in 0..w {
+                match buf.get(sx, sy) {
+                    Some(v) => self.set(x+h-sy-1, y+sy, v),
+                    _ => (),
+                }
+            }
+        }
+    }
 }
 
 pub trait ResizeableBuffer2d: Buffer2d {