Fix transparency bug
This commit is contained in:
parent
c296c8cd08
commit
6b1af0a943
Binary file not shown.
After Width: | Height: | Size: 2.9 KiB |
25
build.rs
25
build.rs
|
@ -1,6 +1,6 @@
|
||||||
use std::fs::create_dir_all;
|
use std::fs::create_dir_all;
|
||||||
|
|
||||||
use image::RgbaImage;
|
use image::{RgbaImage, GenericImage};
|
||||||
use image::imageops::{rotate90, rotate180, rotate270};
|
use image::imageops::{rotate90, rotate180, rotate270};
|
||||||
|
|
||||||
fn superpose(image: &RgbaImage, superposition: &RgbaImage) -> RgbaImage {
|
fn superpose(image: &RgbaImage, superposition: &RgbaImage) -> RgbaImage {
|
||||||
|
@ -20,12 +20,15 @@ fn superpose(image: &RgbaImage, superposition: &RgbaImage) -> RgbaImage {
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
create_dir_all("assets/textures-generated").unwrap();
|
create_dir_all("assets/textures-generated").unwrap();
|
||||||
let background = image::open("assets/textures/grass/background.png").unwrap().to_rgba();
|
let mut texture = image::open("assets/textures/grass.png").unwrap().to_rgba();
|
||||||
let border = image::open("assets/textures/grass/border.png").unwrap().to_rgba();
|
let background = texture.sub_image(0, 0, 32, 32).to_image();
|
||||||
let corner_horiz = image::open("assets/textures/grass/corner-horiz.png").unwrap().to_rgba();
|
let border = texture.sub_image(32, 0, 32, 32).to_image();
|
||||||
let corner_vert = image::open("assets/textures/grass/corner-vert.png").unwrap().to_rgba();
|
let corner_horiz = texture.sub_image(32 * 2 , 0, 32, 32).to_image();
|
||||||
let corner_inside = image::open("assets/textures/grass/corner-inside.png").unwrap().to_rgba();
|
let corner_vert = texture.sub_image(32 * 3, 0, 32, 32).to_image();
|
||||||
let corner_outside = image::open("assets/textures/grass/corner-outside.png").unwrap().to_rgba();
|
let corner_inside = texture.sub_image(32 * 4, 0, 32, 32).to_image();
|
||||||
|
let corner_outside = texture.sub_image(32 * 5, 0, 32, 32).to_image();
|
||||||
|
let mut background_color = texture.sub_image(32 * 6, 0, 32, 32);
|
||||||
|
let background_color = background_color.get_pixel_mut(0, 0);
|
||||||
|
|
||||||
let mut vec = vec![];
|
let mut vec = vec![];
|
||||||
|
|
||||||
|
@ -181,10 +184,12 @@ fn main() {
|
||||||
for (index, image) in vec.into_iter().enumerate() {
|
for (index, image) in vec.into_iter().enumerate() {
|
||||||
for y in 0 .. image.width() {
|
for y in 0 .. image.width() {
|
||||||
for x in 0 .. image.height() {
|
for x in 0 .. image.height() {
|
||||||
*output.get_pixel_mut(x + 32 * index as u32, y) = *background.get_pixel(x, y);
|
|
||||||
let new_pixel = image.get_pixel(x, y);
|
let new_pixel = image.get_pixel(x, y);
|
||||||
if new_pixel[3] > 0 {
|
if new_pixel != background_color {
|
||||||
*output.get_pixel_mut(x + 32 * index as u32, y) = *new_pixel;
|
*output.get_pixel_mut(x + 32 * index as u32, y) = *background.get_pixel(x, y);
|
||||||
|
if new_pixel[3] > 0 {
|
||||||
|
*output.get_pixel_mut(x + 32 * index as u32, y) = *new_pixel;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue