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