about summary refs log tree commit diff
path: root/src/image.rs
diff options
context:
space:
mode:
authorgennyble <gen@nyble.dev>2024-12-07 15:37:19 -0600
committergennyble <gen@nyble.dev>2024-12-07 15:37:19 -0600
commitde63314d720a89fbccb03445a207f01812882eeb (patch)
tree3516e0da50a00db0eeb299520b255c5d50a5b579 /src/image.rs
parent67321406a514a9686eb07318894ed3d8964927cc (diff)
downloadreally-etches-de63314d720a89fbccb03445a207f01812882eeb.tar.gz
really-etches-de63314d720a89fbccb03445a207f01812882eeb.zip
Attempt to fix (6)
Diffstat (limited to 'src/image.rs')
-rw-r--r--src/image.rs17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/image.rs b/src/image.rs
index c1e67db..177eff2 100644
--- a/src/image.rs
+++ b/src/image.rs
@@ -88,12 +88,21 @@ impl Image {
 	/// draws a rect of the specified width at that location.
 	pub fn line(&mut self, p1: Vec2<u32>, p2: Vec2<u32>, width: u32, clr: Color) {
 		let start_x = p1.x.min(p2.x) as f32;
-		let start_y = p1.y.min(p2.y) as f32;
+		let mut start_y = p1.y.min(p2.y) as f32;
 		let end_x = p1.x.max(p2.x) as f32;
-		let end_y = p1.y.max(p2.y) as f32;
+		let mut end_y = p1.y.max(p2.y) as f32;
+
+		if start_y < end_y && start_x < end_x {
+			// this just swaps the problem.
+			//FIXME: genny- 2024-12
+			let temp_y = start_y;
+			start_y = end_y;
+			end_y = temp_y;
+		}
 
-		tracing::trace!("start_x = {start_x} / end_x = {end_x}");
-		tracing::trace!("start_y = {start_y} / end_y = {end_y}");
+		tracing::trace!("LINE");
+		tracing::trace!("\tstart_x = {start_x} / end_x = {end_x}");
+		tracing::trace!("\tstart_y = {start_y} / end_y = {end_y}");
 
 		let dx = end_x - start_x;
 		let dy = end_y - start_y;