Compare commits

..

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

View File

@ -106,26 +106,12 @@ label.readout {
(g:stroke) (g:stroke)
(g:restore))))) (g:restore)))))
(fn label-coords [{ : points } bounds] (fn label-coords [line bounds]
(var biggest 0) (case line.points
(var biggest-n 0) [[sx sy] & more]
(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))]
(values (values
(* tile-size (- x bounds.min.x)) (* tile-size (- sx bounds.min.x))
(* tile-size (- y bounds.min.y)) (* tile-size (- sy bounds.min.y)))))
angle)))
(fn cairo-the-map [window] (fn cairo-the-map [window]
@ -145,7 +131,7 @@ label.readout {
(* tile-size (+ 4 num-tiles-y))) (* tile-size (+ 4 num-tiles-y)))
g (cairo.Context.create map-surface)] 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:rectangle 0 0 (* tile-size num-tiles-x) (* tile-size num-tiles-y))
(g:fill) (g:fill)
@ -157,18 +143,12 @@ label.readout {
(cairo-roads-path g lines bounds) (cairo-roads-path g lines bounds)
(g:set_source_rgb 0.2 0.2 0.2) (g:set_source_rgb 0.2 0.2 0.2)
(g:set_font_size (- road-width 3))
(each [_ line (pairs lines)] (each [_ line (pairs lines)]
(case line.name (case line.name
n (let [(x y angle) (label-coords line bounds)] n (let [(x y) (label-coords line bounds)]
(when (and x y) (when (and x y)
(g:save)
(g:move_to x y) (g:move_to x y)
(g:rotate angle) (g:show_text n)))))
(g:rel_move_to 0 3)
(g:text_path n)
(g:fill)
(g:restore)))))
map-surface))) map-surface)))