diff --git a/pkgs/maps/main.fnl b/pkgs/maps/main.fnl index 57987ae..5715416 100644 --- a/pkgs/maps/main.fnl +++ b/pkgs/maps/main.fnl @@ -33,8 +33,8 @@ label.readout { (os.difftime (os.time localt) (os.time utct)))) -(local map-width 720) -(local map-height 800) +(local viewport-width 720) +(local viewport-height 800) (local tile-size 256) (fn styles [] @@ -49,8 +49,8 @@ label.readout { (local window (Gtk.Window { :title "Map" :name "toplevel" - :default_width map-width - :default_height map-height + :default_width viewport-width + :default_height viewport-height :on_destroy Gtk.main_quit })) @@ -76,10 +76,10 @@ label.readout { (fn map-bounds-tile [tile-x tile-y] - (let [min-tile-x (math.floor (- tile-x (/ map-width tile-size 2))) - max-tile-x (math.floor (+ tile-x (/ map-width tile-size 2))) - min-tile-y (math.floor (- tile-y (/ map-height tile-size 2))) - max-tile-y (math.floor (+ tile-y (/ map-height tile-size 2))) + (let [min-tile-x (math.floor (- tile-x (/ viewport-width tile-size 2))) + max-tile-x (math.floor (+ tile-x (/ viewport-width tile-size 2))) + min-tile-y (math.floor (- tile-y (/ viewport-height tile-size 2))) + max-tile-y (math.floor (+ tile-y (/ viewport-height tile-size 2))) num-tiles-x (+ 1 (- max-tile-x min-tile-x)) num-tiles-y (+ 1 (- max-tile-y min-tile-y))] @@ -100,7 +100,7 @@ label.readout { (let [bounds (map-bounds-tile 65539.5 45014.5)] ;; tile 65539, 45014 is centred on screen. left of it there is space ;; for one tile and right of it likewise. - ;; vertical space for other tiles is (/ (- map-height tile-size) 256) + ;; vertical space for other tiles is (/ (- viewport-height tile-size) 256) ;; => 2.125 tiles, shared equally to top and bottom therefore ;; 1.0625 tiles above and 1.0625 tiles below @@ -240,8 +240,8 @@ label.readout { (fn on-osm-draw [widget g] (let [(tile-x tile-y) (tiles.latlon->tile app-state.lat app-state.lon app-state.zoom) bounds (map-bounds-tile tile-x tile-y) - offset-x (- (* tile-size (- tile-x bounds.min.x)) (/ map-width 2)) - offset-y (- (* tile-size (- tile-y bounds.min.y)) (/ map-height 2))] + offset-x (- (* tile-size (- tile-x bounds.min.x)) (/ viewport-width 2)) + offset-y (- (* tile-size (- tile-y bounds.min.y)) (/ viewport-height 2))] (when (not map-surface) (let [window (widget:get_window)] @@ -255,7 +255,7 @@ label.readout { (g:set_source_surface map-surface (- offset-x) (- offset-y)) (g:set_operator cairo.Operator.SOURCE) - (g:rectangle 0 0 map-width map-height) + (g:rectangle 0 0 viewport-width viewport-height) (g:fill))) @@ -268,7 +268,7 @@ label.readout { (register-widget :osm (Gtk.DrawingArea { - :width map-width :height map-height + :width viewport-width :height viewport-height :on_draw on-osm-draw })))