add pixel dimensions in bounds
This commit is contained in:
parent
1ee968d3a2
commit
2d2f592d73
@ -79,12 +79,19 @@ label.readout {
|
|||||||
(let [min-tile-x (math.floor (- tile-x (/ map-width tile-size 2)))
|
(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)))
|
max-tile-x (math.floor (+ tile-x (/ map-width tile-size 2)))
|
||||||
min-tile-y (math.floor (- tile-y (/ map-height 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)))]
|
max-tile-y (math.floor (+ tile-y (/ map-height tile-size 2)))
|
||||||
|
num-tiles-x (+ 1 (- max-tile-x min-tile-x))
|
||||||
|
num-tiles-y (+ 1 (- max-tile-y min-tile-y))]
|
||||||
|
|
||||||
{
|
{
|
||||||
:min { :x min-tile-x :y min-tile-y }
|
:min { :x min-tile-x :y min-tile-y }
|
||||||
:max { :x max-tile-x :y max-tile-y }
|
:max { :x max-tile-x :y max-tile-y }
|
||||||
:num-tiles-x (+ 1 (- max-tile-x min-tile-x))
|
: num-tiles-x
|
||||||
:num-tiles-y (+ 1 (- max-tile-y min-tile-y))
|
: num-tiles-y
|
||||||
|
:pixels {
|
||||||
|
:x (* tile-size num-tiles-x)
|
||||||
|
:y (* tile-size num-tiles-y)
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
|
|
||||||
;; 720 width is 2.8 * 256 pixel tiles
|
;; 720 width is 2.8 * 256 pixel tiles
|
||||||
@ -195,7 +202,7 @@ label.readout {
|
|||||||
g (cairo.Context.create surface)]
|
g (cairo.Context.create surface)]
|
||||||
|
|
||||||
(g:set_source_rgb 0.7 0.8 0.8)
|
(g:set_source_rgb 0.7 0.8 0.8)
|
||||||
(g:rectangle 0 0 (* tile-size num-tiles-x) (* tile-size num-tiles-y))
|
(g:rectangle 0 0 bounds.pixels.x bounds.pixels.y)
|
||||||
(g:fill)
|
(g:fill)
|
||||||
|
|
||||||
(cairo-roads g lines bounds)
|
(cairo-roads g lines bounds)
|
||||||
@ -235,16 +242,16 @@ label.readout {
|
|||||||
bounds (map-bounds-tile tile-x tile-y)
|
bounds (map-bounds-tile tile-x tile-y)
|
||||||
offset-x (- (* tile-size (- tile-x bounds.min.x)) (/ map-width 2))
|
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-y (- (* tile-size (- tile-y bounds.min.y)) (/ map-height 2))]
|
||||||
|
|
||||||
(when (not map-surface)
|
(when (not map-surface)
|
||||||
(let [window (widget:get_window)
|
(let [window (widget:get_window)]
|
||||||
{ : lat : lon : zoom } app-state]
|
|
||||||
(set map-surface
|
(set map-surface
|
||||||
(doto
|
(doto
|
||||||
(window:create_similar_surface
|
(window:create_similar_surface
|
||||||
cairo.Content.COLOR
|
cairo.Content.COLOR
|
||||||
(* tile-size bounds.num-tiles-x)
|
bounds.pixels.x
|
||||||
(* tile-size bounds.num-tiles-y))
|
bounds.pixels.y)
|
||||||
(draw-onto-map-surface bounds zoom)))))
|
(draw-onto-map-surface bounds app-state.zoom)))))
|
||||||
|
|
||||||
(g:set_source_surface map-surface (- offset-x) (- offset-y))
|
(g:set_source_surface map-surface (- offset-x) (- offset-y))
|
||||||
(g:set_operator cairo.Operator.SOURCE)
|
(g:set_operator cairo.Operator.SOURCE)
|
||||||
|
Loading…
Reference in New Issue
Block a user