commit 0b22a7e5387db67ec7dd51c5964e4d8014a23054
parent beca254bf6e1532c4db8640c71bd96dbdaff8462
Author: Daniel Barlow <dan@telent.net>
Date: Fri, 6 Jun 2025 21:33:19 +0100
pass lat/lon/zoom to draw-onto-map-surface
this removes dependency on global state
and will make it simpler to generate map for arbitrary co-ordinates
Diffstat:
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/pkgs/maps/main.fnl b/pkgs/maps/main.fnl
@@ -180,9 +180,8 @@ label.readout {
(var map-surface nil)
-(fn draw-onto-map-surface [surface]
- (let [{ : lat : lon : zoom } app-state
- { : num-tiles-x : num-tiles-y &as bounds } (map-bounds lat lon zoom)
+(fn draw-onto-map-surface [surface lat lon zoom]
+ (let [{ : num-tiles-x : num-tiles-y &as bounds } (map-bounds lat lon zoom)
road-width 14
lines []]
@@ -237,14 +236,15 @@ label.readout {
offset-x (- (* tile-size (- tile-x bounds.min.x)) (/ map-width 2))
offset-y (- (* tile-size (- tile-y bounds.min.y)) (/ map-height 2))]
(when (not map-surface)
- (let [window (widget:get_window)]
+ (let [window (widget:get_window)
+ { : lat : lon : zoom } app-state]
(set map-surface
(doto
(window:create_similar_surface
cairo.Content.COLOR
(* tile-size bounds.num-tiles-x)
(* tile-size bounds.num-tiles-y))
- draw-onto-map-surface))))
+ (draw-onto-map-surface lat lon zoom)))))
(g:set_source_surface map-surface (- offset-x) (- offset-y))
(g:set_operator cairo.Operator.SOURCE)