add bounds.to-pixels method
This commit is contained in:
+10
-13
@@ -157,6 +157,10 @@ label.readout {
|
||||
:x (/ (+ min-tile-x max-tile-x 1) 2)
|
||||
:y (/ (+ min-tile-y max-tile-y 1) 2)
|
||||
}
|
||||
:to-pixels (fn [tile-x tile-y]
|
||||
(values (* tile-size (- tile-x min-tile-x))
|
||||
(* tile-size (- tile-y min-tile-y))))
|
||||
|
||||
}))
|
||||
|
||||
(define-tests
|
||||
@@ -199,12 +203,9 @@ label.readout {
|
||||
(fn cairo-road-path [g [[sx sy] & points] bounds]
|
||||
(let [min bounds.min
|
||||
{ : line_to } g]
|
||||
(g:move_to (* tile-size (- sx min.x))
|
||||
(* tile-size (- sy min.y)))
|
||||
(g:move_to (bounds.to-pixels sx sy))
|
||||
(each [_ [x y] (ipairs points)]
|
||||
(let [x1 (* tile-size (- x min.x))
|
||||
y1 (* tile-size (- y min.y))]
|
||||
(line_to g x1 y1)))))
|
||||
(line_to g (bounds.to-pixels x y)))))
|
||||
|
||||
(fn cairo-roads [g lines bounds]
|
||||
(g:set_source_rgb 0 0 0)
|
||||
@@ -222,15 +223,12 @@ label.readout {
|
||||
(g:set_source_rgba 0.8 0 0 0.5)
|
||||
(each [_ track (pairs tracks)]
|
||||
(g:set_line_width 10)
|
||||
(let [min bounds.min
|
||||
xypoints (tile-xy-for-track track app-state.zoom)
|
||||
(let [xypoints (tile-xy-for-track track app-state.zoom)
|
||||
[sx sy] (. xypoints 1)
|
||||
{ : line_to } g]
|
||||
(g:move_to (* tile-size (- sx min.x)) (* tile-size (- sy min.y)))
|
||||
(g:move_to (bounds.to-pixels sx sy))
|
||||
(each [_ [x y] (ipairs xypoints)]
|
||||
(let [x1 (* tile-size (- x min.x))
|
||||
y1 (* tile-size (- y min.y))]
|
||||
(line_to g x1 y1))))
|
||||
(line_to g (bounds.to-pixels x y))))
|
||||
(g:stroke)))
|
||||
|
||||
|
||||
@@ -295,8 +293,7 @@ label.readout {
|
||||
w ext.width
|
||||
h ext.height]
|
||||
(when (and tx ty (not (. seen-road-names n)))
|
||||
(let [x (* tile-size (- tx bounds.min.x))
|
||||
y (* tile-size (- ty bounds.min.y))]
|
||||
(let [(x y) (bounds.to-pixels tx ty)]
|
||||
(tset seen-road-names n true)
|
||||
|
||||
(g:save)
|
||||
|
||||
Reference in New Issue
Block a user