(local size 128)
(macro hex [hex]
(local hex-map {:0 0 :1 1 :2 2 :3 3 :4 4 :5 5 :6 6 :7 7 :8 8 :9 9
:a 10 :b 11 :c 12 :d 13 :e 14 :f 15})
(let [hex8 (.. hex "ff")]
(fcollect [i 1 8 2]
(/ (+ (* 16 (. hex-map (string.sub hex8 i i)))
(. hex-map (string.sub hex8 (+ i 1) (+ i 1)))) 255))))
(local red (hex :b45252))
(local white (hex :f2f0e5))
(fn zip [table-1 table-2 into-table?]
(let [len (math.min (# table-1) (# table-2))
out-table (or into-table? [])]
(for [i 0 (- len 1)]
(tset out-table (+ 1 (* 2 i)) (. table-1 (+ i 1)))
(tset out-table (+ 2 (* 2 i)) (. table-2 (+ i 1))))
(tset out-table (+ 1 (* 2 len)) nil)
out-table))
(fn biblically-accurate-hexagon-genesis [radius]
(let [sqrt-radius (* (math.sqrt 3) radius)
double-radius (* radius 2)
x [0 sqrt-radius (- double-radius sqrt-radius) double-radius
double-radius (- double-radius sqrt-radius) sqrt-radius 0]
y [sqrt-radius 0 0 sqrt-radius
(- double-radius sqrt-radius) double-radius double-radius
(- double-radius sqrt-radius)]]
(zip x y)))
(local biblically-accurate-hexagon
(biblically-accurate-hexagon-genesis size))
(fn love.draw []
(love.graphics.clear white)
(love.graphics.push :all)
(love.graphics.setColor red)
(let [(w h) (love.window.getMode)]
(love.graphics.translate (-> w (/ 2) (- size))
(-> h (/ 2) (- size))))
(love.graphics.setLineWidth 16)
(love.graphics.polygon :line biblically-accurate-hexagon)
(love.graphics.pop))