mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 16:21:33 +11:00
Feels cleaner with a bunch of for loops
This commit is contained in:
parent
fdff081c32
commit
3626e2cb18
|
@ -38,29 +38,25 @@ pub(crate) fn generate_code(
|
|||
let tiles_x = image.width / tile_size;
|
||||
let tiles_y = image.height / tile_size;
|
||||
|
||||
let tile_data = (0..tiles_y)
|
||||
.map(|y| {
|
||||
(0..tiles_x).map(move |x| {
|
||||
let palette_index = results.assignments[y * tiles_x + x];
|
||||
let palette = &results.optimised_palettes[palette_index];
|
||||
let mut tile_data = vec![];
|
||||
|
||||
(0..tile_size / 8).map(move |inner_y| {
|
||||
(0..tile_size / 8).map(move |inner_x| {
|
||||
(inner_y * 8..inner_y * 8 + 8).map(move |j| {
|
||||
(inner_x * 8..inner_x * 8 + 8).rev().map(move |i| {
|
||||
let colour = image.colour(x * tile_size + i, y * tile_size + j);
|
||||
palette.colour_index(colour)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
.flatten()
|
||||
.flatten()
|
||||
.flatten()
|
||||
.flatten()
|
||||
.flatten();
|
||||
for y in 0..tiles_y {
|
||||
for x in 0..tiles_x {
|
||||
let palette_index = results.assignments[y * tiles_x + x];
|
||||
let palette = &results.optimised_palettes[palette_index];
|
||||
|
||||
for inner_y in 0..tile_size / 8 {
|
||||
for inner_x in 0..tile_size / 8 {
|
||||
for j in inner_y * 8..inner_y * 8 + 8 {
|
||||
for i in inner_x * 8..inner_x * 8 + 8 {
|
||||
let colour = image.colour(x * tile_size + i, y * tile_size + j);
|
||||
tile_data.push(palette.colour_index(colour));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let assignments = &results.assignments;
|
||||
|
||||
|
|
Loading…
Reference in a new issue