mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-24 08:41:34 +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_x = image.width / tile_size;
|
||||||
let tiles_y = image.height / tile_size;
|
let tiles_y = image.height / tile_size;
|
||||||
|
|
||||||
let tile_data = (0..tiles_y)
|
let mut tile_data = vec![];
|
||||||
.map(|y| {
|
|
||||||
(0..tiles_x).map(move |x| {
|
for y in 0..tiles_y {
|
||||||
|
for x in 0..tiles_x {
|
||||||
let palette_index = results.assignments[y * tiles_x + x];
|
let palette_index = results.assignments[y * tiles_x + x];
|
||||||
let palette = &results.optimised_palettes[palette_index];
|
let palette = &results.optimised_palettes[palette_index];
|
||||||
|
|
||||||
(0..tile_size / 8).map(move |inner_y| {
|
for inner_y in 0..tile_size / 8 {
|
||||||
(0..tile_size / 8).map(move |inner_x| {
|
for inner_x in 0..tile_size / 8 {
|
||||||
(inner_y * 8..inner_y * 8 + 8).map(move |j| {
|
for j in inner_y * 8..inner_y * 8 + 8 {
|
||||||
(inner_x * 8..inner_x * 8 + 8).rev().map(move |i| {
|
for i in inner_x * 8..inner_x * 8 + 8 {
|
||||||
let colour = image.colour(x * tile_size + i, y * tile_size + j);
|
let colour = image.colour(x * tile_size + i, y * tile_size + j);
|
||||||
palette.colour_index(colour)
|
tile_data.push(palette.colour_index(colour));
|
||||||
})
|
}
|
||||||
})
|
}
|
||||||
})
|
}
|
||||||
})
|
}
|
||||||
})
|
}
|
||||||
})
|
}
|
||||||
.flatten()
|
|
||||||
.flatten()
|
|
||||||
.flatten()
|
|
||||||
.flatten()
|
|
||||||
.flatten();
|
|
||||||
|
|
||||||
let assignments = &results.assignments;
|
let assignments = &results.assignments;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue