mindustry logic execution, map- and schematic- parsing and rendering
-rw-r--r--mindus/Cargo.toml2
-rw-r--r--mindus/src/data/renderer.rs32
-rw-r--r--mindus/src/lib.rs2
3 files changed, 23 insertions, 13 deletions
diff --git a/mindus/Cargo.toml b/mindus/Cargo.toml
index 106e8e0..e9b73aa 100644
--- a/mindus/Cargo.toml
+++ b/mindus/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "mindus"
-version = "5.0.12"
+version = "5.0.13"
edition = "2021"
description = "A library for working with mindustry data formats (eg schematics and maps) (fork of plandustry)"
authors = [
diff --git a/mindus/src/data/renderer.rs b/mindus/src/data/renderer.rs
index d66e0f4..410ed48 100644
--- a/mindus/src/data/renderer.rs
+++ b/mindus/src/data/renderer.rs
@@ -98,17 +98,22 @@ impl Renderable for Schematic {
/// let output /*: Image */ = s.render();
/// ```
fn render(&self) -> Image<Vec<u8>, 3> {
+ let scale = if self.width + self.height > 500 {
+ Scale::Quarter
+ } else {
+ Scale::Full
+ };
// fill background
- // SAFETY: metal-floor is 32x32, the output is a multiple of 32
+ // SAFETY: metal-floor is scalexscale, the output is a multiple of scale
let mut bg = unsafe {
- load!("metal-floor", Scale::Full).borrow().repeated(
- ((self.width + 2) * 32) as u32,
- ((self.height + 2) * 32) as u32,
+ load!("metal-floor", scale).borrow().repeated(
+ scale * (self.width + 2) as u32,
+ scale * (self.height + 2) as u32,
)
};
let mut canvas = Image::alloc(
- ((self.width + 2) * 32) as u32,
- ((self.height + 2) * 32) as u32,
+ scale * (self.width + 2) as u32,
+ scale * (self.height + 2) as u32,
);
for (GridPos(x, y), tile) in self.block_iter() {
let ctx = tile.block.wants_context().then(|| {
@@ -130,16 +135,21 @@ impl Renderable for Schematic {
.image(
ctx.as_ref(),
tile.get_rotation().unwrap_or(Rotation::Up),
- Scale::Full,
+ scale,
)
.borrow(),
- (x + 1) * 32,
- (y + 1) * 32,
+ scale * (x + 1),
+ scale * (y + 1),
)
};
}
- canvas.as_mut().shadow();
- unsafe { bg.overlay_blended(&canvas) };
+
+ if matches!(scale, Scale::Full) {
+ canvas.as_mut().shadow();
+ unsafe { bg.overlay_blended(&canvas) };
+ } else {
+ unsafe { bg.overlay(&canvas) };
+ }
bg
}
}
diff --git a/mindus/src/lib.rs b/mindus/src/lib.rs
index f9a0d28..7ed688b 100644
--- a/mindus/src/lib.rs
+++ b/mindus/src/lib.rs
@@ -9,8 +9,8 @@
clippy::dbg_macro,
clippy::perf
)]
-pub mod color_mapping;
pub mod block;
+pub mod color_mapping;
pub mod content;
pub mod data;
pub mod fluid;