Compare commits

..

No commits in common. "0f64758e77976c5ab2d33a9c7e221fe9f3308e92" and "2906360c2ec9025c83eda5b1bcb690a011790967" have entirely different histories.

View File

@ -106,26 +106,12 @@ label.readout {
(g:stroke)
(g:restore)))))
(fn label-coords [{ : points } bounds]
(var biggest 0)
(var biggest-n 0)
(for [i 2 (# points)]
(let [[x1 y1] (. points (- i 1))
[x2 y2] (. points i)
dist
(+ (* (- x2 x1) (- x2 x1))
(* (- y2 y1) (- y2 y1)))]
(when (>= dist biggest)
(set biggest dist)
(set biggest-n (- i 1)))))
(let [[x y] (. points biggest-n)
[nx ny] (. points (+ 1 biggest-n))
angle (math.atan (- ny y) (- nx x))]
(fn label-coords [line bounds]
(case line.points
[[sx sy] & more]
(values
(* tile-size (- x bounds.min.x))
(* tile-size (- y bounds.min.y))
angle)))
(* tile-size (- sx bounds.min.x))
(* tile-size (- sy bounds.min.y)))))
(fn cairo-the-map [window]
@ -145,7 +131,7 @@ label.readout {
(* tile-size (+ 4 num-tiles-y)))
g (cairo.Context.create map-surface)]
(g:set_source_rgb 0.7 0.8 0.8)
(g:set_source_rgb 1 1 1)
(g:rectangle 0 0 (* tile-size num-tiles-x) (* tile-size num-tiles-y))
(g:fill)
@ -157,18 +143,12 @@ label.readout {
(cairo-roads-path g lines bounds)
(g:set_source_rgb 0.2 0.2 0.2)
(g:set_font_size (- road-width 3))
(each [_ line (pairs lines)]
(case line.name
n (let [(x y angle) (label-coords line bounds)]
n (let [(x y) (label-coords line bounds)]
(when (and x y)
(g:save)
(g:move_to x y)
(g:rotate angle)
(g:rel_move_to 0 3)
(g:text_path n)
(g:fill)
(g:restore)))))
(g:show_text n)))))
map-surface)))