This is a must read if you're working with hex grids: <a href="https://www.redblobgames.com/grids/hexagons/" rel="nofollow">https://www.redblobgames.com/grids/hexagons/</a>
I see a lot of convoluted CSS things like this. Is there not much awareness of SVG in the webdev community, or is there some other reason people don't want to use it?
Oooh, nice.<p>I have worked with hexes in little side project games, it was a difficult process and I went through a phase of trying to home-roll canvas drawing of hexes (and making some interesting looking bugs). I ended up using a js library (Konva / <a href="https://konvajs.org/" rel="nofollow">https://konvajs.org/</a>) which was pretty easy to implement.<p>One completed (albeit ugly) project was an implementation of a minigame I played in Magnum Opus:<p><a href="https://game.manfrincdn.com/#/" rel="nofollow">https://game.manfrincdn.com/#/</a><p>It's been a little project kicking around that I want to make a hex game engine of sorts in Vue. The difficult part I keep running in to is connecting the state of the engine (in vue) with the state of the canvas (outside). I've ended up often hitting lower level APIs to watch/update/rerender parts, but at that point I feel like I end up reimplementing parts of vue within itself, and that nagging 'you are missing an obvious solution' worm starts up.<p>A pure CSS approach would make this a lot simpler, because there'd be no need to do any manual wiring up of state to canvas state, you'd just let vue handle that cycle because that's its core competency.
Kind of a nostalgia thing to see this, as one of my earliest answers on gamedev stack was about creating a hex map (See <a href="https://gamedev.stackexchange.com/questions/6382/how-to-create-a-hexagon-world-map-in-php-from-a-database-for-a-browser-based-str" rel="nofollow">https://gamedev.stackexchange.com/questions/6382/how-to-crea...</a>)<p>I cheated and used hex-shaped png files but looking back using CSS to just auto-shape the PNG would be good.<p>That said, if you ARE using textures in the hexes and you'd like to actually tile them, you'll have to explicitly design an image that will tile. So you might as well just create hex shaped images like this and forget getting too fancy.
PSA: don't open this on Safari on a Mac book Pro, it'll either take a while to load or it'll freeze your computer if you have other heavy processes running. Chrome works fine.
This totally reminded me of Tantek's site <a href="http://tantek.com/map.html" rel="nofollow">http://tantek.com/map.html</a><p>Wayback: <a href="http://web.archive.org/web/20020321021851/http://tantek.com/map.html" rel="nofollow">http://web.archive.org/web/20020321021851/http://tantek.com/...</a>
I ran into the problem too that CSS-counters are strings and not integers. Can anyone explain the reasoning? It's understandable that the displayed value is a string but the (sub)counters themselves could as well been done as integers imo.
Can anybody explain to me why I would use the CSS grid to accomplish this and not negative margins on inline divs? The latter is how I immediately guessed that this would be implemented. What would be the advantages of the grid method?