aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/app.rs6
-rw-r--r--src/bitmap.rs7
-rw-r--r--src/lisp/eval.rs4
3 files changed, 13 insertions, 4 deletions
diff --git a/src/app.rs b/src/app.rs
index 68d687f..3e7ac0f 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -1,5 +1,5 @@
1use crate::{ 1use crate::{
2 bitmap::{abs_difference, positive_angle_with_x, Axis, MapPoint, Pixmap}, 2 bitmap::{abs_difference, manhattan, positive_angle_with_x, Axis, MapPoint, Pixmap},
3 brush::{Brush, CircleBrush, LineBrush, RectSelectBrush}, 3 brush::{Brush, CircleBrush, LineBrush, RectSelectBrush},
4 cache::Cache, 4 cache::Cache,
5 command::CommandBox, 5 command::CommandBox,
@@ -481,8 +481,9 @@ impl<'ctx> AppState<'ctx> {
481 &mut self.canvas, 481 &mut self.canvas,
482 self.ttf_context, 482 self.ttf_context,
483 format!( 483 format!(
484 "{:.width$}°", 484 "{:.width$}°, {}",
485 angle, 485 angle,
486 manhattan(from, to.into()),
486 width = if (angle - ANGLE).abs() < 1e-3 { 3 } else { 0 } 487 width = if (angle - ANGLE).abs() < 1e-3 { 3 } else { 0 }
487 ), 488 ),
488 PINK, 489 PINK,
@@ -1082,6 +1083,7 @@ impl<'ctx> AppState<'ctx> {
1082 } 1083 }
1083 } 1084 }
1084 } 1085 }
1086 self.cache();
1085 self.redraw(); 1087 self.redraw();
1086 } 1088 }
1087 } 1089 }
diff --git a/src/bitmap.rs b/src/bitmap.rs
index 0b1754a..ff41cb8 100644
--- a/src/bitmap.rs
+++ b/src/bitmap.rs
@@ -333,3 +333,10 @@ pub fn positive_angle_with_x(start: MapPoint, end: MapPoint) -> f64 {
333 let denum = (end.x as f64 - start.x as f64).abs(); 333 let denum = (end.x as f64 - start.x as f64).abs();
334 (numer / denum).atan().to_degrees() 334 (numer / denum).atan().to_degrees()
335} 335}
336
337pub fn manhattan(
338 MapPoint { x: sx, y: sy }: MapPoint,
339 MapPoint { x: ex, y: ey, .. }: MapPoint,
340) -> u32 {
341 abs_difference(sx, ex) + abs_difference(sy, ey)
342}
diff --git a/src/lisp/eval.rs b/src/lisp/eval.rs
index c5e4ed0..1b277f9 100644
--- a/src/lisp/eval.rs
+++ b/src/lisp/eval.rs
@@ -336,9 +336,9 @@ pub fn lookup(env_list: &[Environment], key: &str) -> Result<LispExpr, LispError
336 .ok_or(EvalError::UnboundVariable(key.into()))?) 336 .ok_or(EvalError::UnboundVariable(key.into()))?)
337} 337}
338 338
339pub fn lookup_mut<'a, 'b>( 339pub fn lookup_mut<'a>(
340 env_list: &'a mut [Environment], 340 env_list: &'a mut [Environment],
341 key: &'b str, 341 key: &'_ str,
342) -> Result<&'a mut LispExpr, LispError> { 342) -> Result<&'a mut LispExpr, LispError> {
343 Ok(env_list 343 Ok(env_list
344 .iter_mut() 344 .iter_mut()