Browse Source

textium::texture: implement a rotated patch method for the packer

master
Erin 8 years ago
parent
commit
9690084c28
1 changed files with 16 additions and 0 deletions
  1. +16
    -0
      textium/src/texture.rs

+ 16
- 0
textium/src/texture.rs View File

@ -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 { pub trait ResizeableBuffer2d: Buffer2d {


Loading…
Cancel
Save