This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-12-08
Channels
- # adventofcode (49)
- # announcements (2)
- # architecture (4)
- # babashka (48)
- # babashka-sci-dev (4)
- # beginners (7)
- # biff (1)
- # calva (14)
- # cider (6)
- # clj-kondo (1)
- # clj-yaml (1)
- # cljsrn (3)
- # clojure (14)
- # clojure-art (12)
- # clojure-europe (62)
- # clojure-nl (1)
- # clojure-norway (35)
- # clojure-uk (5)
- # clojurescript (18)
- # clr (4)
- # community-development (9)
- # conjure (2)
- # core-async (3)
- # cursive (2)
- # datomic (2)
- # emacs (8)
- # events (3)
- # graalvm (1)
- # helix (6)
- # holy-lambda (3)
- # jobs (1)
- # off-topic (16)
- # polylith (30)
- # practicalli (11)
- # reitit (5)
- # shadow-cljs (14)
- # slack-help (10)
- # xtdb (6)
I'm not grokking something about Clojure2D + fastmath.grid.
(def g (grid/grid :flat-hex 20))
(doseq [x (range 0 20)
y (range 0 20)]
(-> canvas (c2d/grid-cell grid x y true)
I'd expect that to draw a 20x20 grid of hexes. But I just get a tiny set of hexes:grid-cell
expects screen coordinates and draws the enclosing cell.
size of grid
is the size of the cell.
💡 1
I see now that it's not clear enough. I'll update docs and maybe introduce another function for cell coordinates.
👍 1
(let [grid (grid/grid :flat-hex 20.0)]
(with-canvas [c (canvas 600 600)]
(set-background c 0)
(doseq [q (range 0 20)
r (range 0 20)
:let [m (grid/cell->anchor grid q r)]]
(-> c (grid-cell grid (m 0) (m 1) true)))
(show-window {:canvas c})))
Today I'll deploy a snapshot which will introduce grid-qr-cell
function.
(let [grid (grid/grid :flat-hex 20.0)]
(with-canvas [c (canvas 600 600)]
(set-background c 0)
(doseq [q (range 0 20)
r (range 0 20)]
(-> c (grid-qr-cell grid q r true)))
(show-window {:canvas c})))
Here is the list of other coordinate systems and conversion methods. Maybe I add them soon: https://www.redblobgames.com/grids/hexagons/#coordinates