Implement tiling

This commit is contained in:
Surma
2019-02-15 19:36:28 +01:00
parent fadb53f075
commit 6baa5900fc
2 changed files with 12 additions and 6 deletions

View File

@@ -22,6 +22,8 @@ impl<T> HardUnwrap<T> for Option<T> {
} }
} }
const TILE_SIZE: usize = 64;
#[no_mangle] #[no_mangle]
fn rotate(width: usize, height: usize, rotate: usize) { fn rotate(width: usize, height: usize, rotate: usize) {
let num_pixels = width * height; let num_pixels = width * height;
@@ -41,8 +43,10 @@ fn rotate(width: usize, height: usize, rotate: usize) {
90 => { 90 => {
let new_width = height; let new_width = height;
let _new_height = width; let _new_height = width;
for y in 0..height { for y_start in (0..height).step_by(TILE_SIZE) {
for x in 0..width { for x_start in (0..width).step_by(TILE_SIZE) {
for y in y_start..(y_start + TILE_SIZE).min(height) {
for x in x_start..(x_start + TILE_SIZE).min(width) {
let new_x = (new_width - 1) - y; let new_x = (new_width - 1) - y;
let new_y = x; let new_y = x;
*out_b.get_mut(new_y * new_width + new_x).unwrap_hard() = *out_b.get_mut(new_y * new_width + new_x).unwrap_hard() =
@@ -50,6 +54,8 @@ fn rotate(width: usize, height: usize, rotate: usize) {
} }
} }
} }
}
}
180 => std::process::abort(), 180 => std::process::abort(),
270 => std::process::abort(), 270 => std::process::abort(),
_ => std::process::abort(), _ => std::process::abort(),

Binary file not shown.