Implement 180 and 270

This commit is contained in:
Surma
2019-02-15 19:47:16 +01:00
parent 6baa5900fc
commit d205ae206f
2 changed files with 21 additions and 2 deletions

View File

@@ -56,8 +56,27 @@ fn rotate(width: usize, height: usize, rotate: usize) {
}
}
}
180 => std::process::abort(),
270 => std::process::abort(),
180 => {
for i in 0..num_pixels {
*out_b.get_mut(num_pixels - 1 - i).unwrap_hard() = *in_b.get(i).unwrap_hard();
}
}
270 => {
let new_width = height;
let new_height = width;
for y_start in (0..height).step_by(TILE_SIZE) {
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 = y;
let new_y = new_height - 1 - x;
*out_b.get_mut(new_y * new_width + new_x).unwrap_hard() =
*in_b.get(y * width + x).unwrap_hard();
}
}
}
}
}
_ => std::process::abort(),
}
}

Binary file not shown.