biscuit

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

commit 8637731c60c3575e10e23ecca2bf821991dffd73
parent b3f0628948b8ef8678db703aea18e36e252b8c92
Author: Daniel Barlow <dan@telent.net>
Date:   Wed, 11 Jun 2025 17:37:10 +0100

repaint map when orientation changes

this is in preparation for writing the road labels on the right way
up

Diffstat:
Mpkgs/maps/main.fnl | 24++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/pkgs/maps/main.fnl b/pkgs/maps/main.fnl @@ -78,7 +78,7 @@ label.readout { :lon 0 :zoom 17 :course 0 ; direction of travel - :orientation 0 ; map rotation angle from north + :orientation {:target 0 :actual 0} ; map rotation angle from north :tiles {} } ) @@ -251,7 +251,7 @@ label.readout { (draw-onto-map-surface bounds app-state.zoom))))) (g:translate (+ (/ viewport-width 2)) (+ (/ viewport-height 2))) - (g:rotate (* (/ (- 360 app-state.orientation) 180) math.pi)) + (g:rotate (* (/ (- 360 app-state.orientation.actual) 180) math.pi)) (g:translate (- (/ viewport-width 2)) (- (/ viewport-height 2))) (g:set_source_surface map-surface (- offset-x) (- offset-y)) @@ -302,10 +302,18 @@ label.readout { (when (not (bounds= old-bounds bounds)) (fetch-tiles bounds app-state.tiles app-state.zoom) (set map-surface nil))) - (when (> (math.abs (- app-state.orientation app-state.course)) 20) - (set app-state.orientation - (+ app-state.orientation - (* 0.05 (- app-state.course app-state.orientation))))) + + (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)) + (set map-surface nil)) + + (when (not (= app-state.orientation.target app-state.orientation.actual)) + (set app-state.orientation.actual + (+ app-state.orientation.actual + (* 0.05 (- app-state.orientation.target app-state.orientation.actual)))) + ) + (each [name widget (pairs state-widgets)] (case name :speed (widget:set_label @@ -341,7 +349,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) + (g:rotate (* (/ (- app-state.course app-state.orientation.actual) 180) math.pi)) (g:translate (// height -2) (// height -2)) (g:set_line_width 4) @@ -373,7 +381,7 @@ label.readout { (g:stroke) (g:translate (// height 2) (// height 2)) - (g:rotate (- (deg->rad app-state.orientation))) + (g:rotate (- (deg->rad app-state.orientation.actual))) (g:translate (// height -2) (// height -2)) (g:set_line_width 2)