mindustry logic execution, map- and schematic- parsing and rendering
use circle() when sides too high
bendn 2023-10-09
parent 10968c7 · commit 5cb812b
-rw-r--r--lemu/Cargo.toml2
-rw-r--r--lemu/src/instructions/draw.rs24
2 files changed, 17 insertions, 9 deletions
diff --git a/lemu/Cargo.toml b/lemu/Cargo.toml
index 130e8cc..13604c0 100644
--- a/lemu/Cargo.toml
+++ b/lemu/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "lemu"
-version = "0.2.11"
+version = "0.2.12"
edition = "2021"
description = "M-LOG runner"
authors = ["bend-n <[email protected]>"]
diff --git a/lemu/src/instructions/draw.rs b/lemu/src/instructions/draw.rs
index 8735260..1e57447 100644
--- a/lemu/src/instructions/draw.rs
+++ b/lemu/src/instructions/draw.rs
@@ -277,14 +277,22 @@ impl<'v> DrawInstruction<'v> for Poly<'v> {
image: &mut Image<&mut [u8], 4>,
state: &mut DisplayState,
) {
- let pos = map!(point!([email protected]), |n| n as f32);
- image.poly(
- pos,
- get_num!(mem.get(&self.sides)).round() as usize,
- get_num!(mem.get(&self.radius)) as f32,
- get_num!(mem.get(&self.rot)) as f32,
- state.col(),
- );
+ let sides = get_num!(mem.get(&self.sides)).round() as usize;
+ if sides < 90 {
+ image.poly(
+ map!(point!([email protected]), |n| n as f32),
+ sides,
+ get_num!(mem.get(&self.radius)) as f32,
+ get_num!(mem.get(&self.rot)) as f32,
+ state.col(),
+ );
+ } else {
+ image.circle(
+ map!(point!([email protected]), |n: f64| n.round() as i32),
+ get_num!(mem.get(&self.radius)).round() as i32,
+ state.col(),
+ );
+ }
}
}