biscuit

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit bf9fd57bf4c46d504fb7d4877af559f5a374c19b
parent 60d675bc42ac97e541ab78b54ffe3306deb3f2fa
Author: Daniel Barlow <dan@telent.net>
Date:   Fri, 13 Mar 2026 23:26:31 +0000

remove unneeded orientation-target

as now we can use course directly

Diffstat:
Mpkgs/maps/main.fnl | 33+++++++++++++++------------------
1 file changed, 15 insertions(+), 18 deletions(-)

diff --git a/pkgs/maps/main.fnl b/pkgs/maps/main.fnl @@ -94,8 +94,7 @@ label.readout { :lon 0 :zoom 17 :course 0 ; direction of travel - :orientation-target 0 ; map rotation angle from north - :orientation-actual 0 ; map rotation angle from north + :orientation 0 ; map rotation angle from north :rotation-speed 0 :tiles {} } @@ -253,7 +252,7 @@ label.readout { (g:fill) (g:translate (+ (// bounds.pixels.x 2)) (+ (// bounds.pixels.y 2))) - (g:rotate (deg->rad (- app-state.orientation-target))) + (g:rotate (deg->rad (- app-state.course))) (g:translate (- (// bounds.pixels.x 2)) (- (// bounds.pixels.y 2))) (cairo-roads g lines bounds) @@ -275,7 +274,7 @@ label.readout { (g:move_to x y) (let [theta (clamp-angle - (- angle (deg->rad app-state.orientation-target)))] + (- angle (deg->rad app-state.course)))] (if (and (> theta 0) (< theta math.pi)) (g:rotate (- angle (/ math.pi 2))) (g:rotate (- angle (* math.pi 1.5))))) @@ -295,7 +294,7 @@ label.readout { offset-y (/ (- viewport-height bounds.pixels.y) 2) x-to-centre (- tile-x bounds.centre.x) y-to-centre (- tile-y bounds.centre.y) - angle (- (/ (* math.pi app-state.orientation-target) 180)) + angle (- (/ (* math.pi app-state.course) 180)) x-to-centre-rot (- (* x-to-centre (math.cos angle)) (* y-to-centre (math.sin angle))) y-to-centre-rot (+ (* x-to-centre (math.sin angle)) @@ -313,9 +312,9 @@ label.readout { (draw-onto-map-surface bounds app-state.zoom))))) - (when (not (= app-state.orientation-actual app-state.orientation-target)) + (when (not (= app-state.orientation app-state.course)) (g:translate (+ (/ viewport-width 2)) (+ (/ viewport-height 2))) - (g:rotate (* (/ (- 360 (- app-state.orientation-actual app-state.orientation-target)) 180) math.pi)) + (g:rotate (* (/ (- 360 (- app-state.orientation app-state.course)) 180) math.pi)) (g:translate (- (/ viewport-width 2)) (- (/ viewport-height 2)))) (g:set_source_surface map-surface @@ -375,14 +374,12 @@ label.readout { (fetch-tiles bounds app-state.tiles app-state.zoom) (set map-surface nil))) - (when (> (math.abs (- app-state.orientation-target app-state.course)) 20) - (set app-state.orientation-target app-state.course) -; (-> state-widgets.rose (: :get_window) (: :invalidate_rect nil)) + (when (not (= old-state.course app-state.course)) (set map-surface nil)) - - (when (not (= app-state.orientation-target app-state.orientation-actual)) - (let [distance (- app-state.orientation-target app-state.orientation-actual) + (when (or (not (= app-state.rotation-speed 0)) + (not (< -10 (- app-state.course app-state.orientation) 10))) + (let [distance (- app-state.course app-state.orientation) direction (if (> distance 0) 1 -1) abs-distance (* direction distance) max-accel 0.2 @@ -398,8 +395,8 @@ label.readout { (- max-speed (math.abs app-state.rotation-speed)))))] (if (< -0.2 a 0.2) 0 a)))))) - (set app-state.orientation-actual (+ app-state.orientation-actual - app-state.rotation-speed)) + (set app-state.orientation (+ app-state.orientation + app-state.rotation-speed)) (each [name widget (pairs state-widgets)] (case name @@ -412,7 +409,7 @@ label.readout { (= old-state.lat app-state.lat) (= old-state.lon app-state.lon) (= old-state.orientation-actual - app-state.orientation-actual) + app-state.orientation) )) (: (widget:get_window) :invalidate_rect nil)) :arrow (: (widget:get_window) :invalidate_rect nil) @@ -445,7 +442,7 @@ label.readout { (fn [self g] (g:set_source_rgb 0.4 0.0 0.1) (g:translate (// height 2) (// height 2)) - (g:rotate (* (/ (- app-state.course app-state.orientation-actual) + (g:rotate (* (/ (- app-state.course app-state.orientation) 180) math.pi)) (g:translate (// height -2) (// height -2)) (g:set_line_width 4) @@ -477,7 +474,7 @@ label.readout { (g:stroke) (g:translate (// height 2) (// height 2)) - (g:rotate (- (deg->rad app-state.orientation-actual))) + (g:rotate (- (deg->rad app-state.orientation))) (g:translate (// height -2) (// height -2)) (g:set_line_width 2)