mindustry logic execution, map- and schematic- parsing and rendering
blur better
bendn 2023-11-01
parent 49e801f · commit 36d9397
-rw-r--r--mindus/Cargo.toml5
-rw-r--r--mindus/src/data/renderer.rs8
-rw-r--r--mindus/src/utils/image/mod.rs10
3 files changed, 6 insertions, 17 deletions
diff --git a/mindus/Cargo.toml b/mindus/Cargo.toml
index 22fd88c..2efea5f 100644
--- a/mindus/Cargo.toml
+++ b/mindus/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "mindus"
-version = "5.0.8"
+version = "5.0.9"
edition = "2021"
description = "A library for working with mindustry data formats (eg schematics and maps) (fork of plandustry)"
authors = [
@@ -22,10 +22,9 @@ amap = "0.1"
color-hex = "0.2"
thiserror = "1.0"
bobbin-bits = "0.1"
-blurslice = { version = "0.1" }
enum_dispatch = "0.3"
phf = { version = "0.11", features = ["macros"] }
-fimg = { version = "0.4.22", features = ["scale"], default-features = false }
+fimg = { version = "0.4.23", features = ["scale", "blur"], default-features = false }
[features]
bin = ["fimg/save"]
diff --git a/mindus/src/data/renderer.rs b/mindus/src/data/renderer.rs
index ab8554b..d66e0f4 100644
--- a/mindus/src/data/renderer.rs
+++ b/mindus/src/data/renderer.rs
@@ -138,12 +138,8 @@ impl Renderable for Schematic {
)
};
}
- if self.width * self.height > 2250 {
- unsafe { bg.overlay(&canvas) };
- } else {
- canvas.as_mut().shadow();
- unsafe { bg.overlay_blended(&canvas) };
- }
+ canvas.as_mut().shadow();
+ unsafe { bg.overlay_blended(&canvas) };
bg
}
}
diff --git a/mindus/src/utils/image/mod.rs b/mindus/src/utils/image/mod.rs
index 6f80a86..08aa13c 100644
--- a/mindus/src/utils/image/mod.rs
+++ b/mindus/src/utils/image/mod.rs
@@ -37,7 +37,7 @@ impl ImageUtils for Image<&mut [u8], 4> {
}
fn shadow(&mut self) -> &mut Self {
- let mut shadow: Image<Vec<u8>, 4> = self.to_owned();
+ let mut shadow = self.to_owned().boxed();
for [r, g, b, a] in shadow.chunked_mut() {
if *a < 128 {
*r /= 10;
@@ -45,13 +45,7 @@ impl ImageUtils for Image<&mut [u8], 4> {
*b /= 10;
}
}
- blurslice::gaussian_blur_bytes::<4>(
- unsafe { shadow.buffer_mut() },
- self.width() as usize,
- self.height() as usize,
- 9.0,
- )
- .unwrap();
+ shadow.blur(22);
for ([r, g, b, a], &[from_r, from_g, from_b, from_a]) in
self.chunked_mut().zip(shadow.chunked())
{