{"id":40916074,"url":"https://github.com/gravitton/hexagon","last_synced_at":"2026-04-25T19:02:36.623Z","repository":{"id":318296941,"uuid":"1043336797","full_name":"gravitton/hexagon","owner":"gravitton","description":"Hexagon library for game development","archived":false,"fork":false,"pushed_at":"2026-04-19T13:25:41.000Z","size":45,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-19T15:29:52.494Z","etag":null,"topics":["game-development","go","golang","hex","hexagon","hexagonal-grid","hexgrid"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gravitton.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-23T16:33:53.000Z","updated_at":"2026-04-19T13:25:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"4de62b53-9e2b-4f13-845e-8a49640fa444","html_url":"https://github.com/gravitton/hexagon","commit_stats":null,"previous_names":["gravitton/hexagon"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/gravitton/hexagon","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gravitton%2Fhexagon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gravitton%2Fhexagon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gravitton%2Fhexagon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gravitton%2Fhexagon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gravitton","download_url":"https://codeload.github.com/gravitton/hexagon/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gravitton%2Fhexagon/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32273223,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-25T18:29:39.964Z","status":"ssl_error","status_checked_at":"2026-04-25T18:29:32.149Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["game-development","go","golang","hex","hexagon","hexagonal-grid","hexgrid"],"created_at":"2026-01-22T03:15:22.466Z","updated_at":"2026-04-25T19:02:36.618Z","avatar_url":"https://github.com/gravitton.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hexagon\n\n[![Latest Stable Version][ico-release]][link-release]\n[![Build Status][ico-workflow]][link-workflow]\n[![Coverage Status][ico-coverage]][link-coverage]\n[![Go Report Card][ico-go-report-card]][link-go-report-card]\n[![Go Dev Reference][ico-go-dev-reference]][link-go-dev-reference]\n[![Software License][ico-license]][link-licence]\n\nHexagon library for game development.\n\n- Axial (cube) coordinates with arithmetic, distance, and neighbor lookup\n- Area and perimeter traversal: range, ring, and spiral\n- Line drawing, line-of-sight, and field-of-view\n- Rotation and reflection in cube space\n- Direction enum with opposite and rotation helpers\n- Seven coordinate systems with lossless round-trip conversion\n- Pixel-space layout for flat-top and pointy-top orientations\n\n## Installation\n\n```bash\ngo get github.com/gravitton/hexagon\n```\n\n\n## Usage\n\n```go\nimport (\n\thex \"github.com/gravitton/hexagon\"\n\tgeom \"github.com/gravitton/geometry\"\n)\n\n// create hexagon in axial coordinates (q,r)\na := hex.Coord(1, -2)\nb := hex.Coord(0, 3)\n\n// arithmetic and distance\nc := a.Add(b)\nd := a.Subtract(b)\ne := a.Multiply(2)\ndistance := a.DistanceTo(b)\n\n// neighbors\nneighbors := a.Neighbors()\nneighbor := a.Neighbor(hex.QPlus)\n\n// area traversal\narea := b.Range(2)   // all hexes within radius 2 (filled)\nring := b.Ring(2)    // hexes at exactly distance 2 (perimeter)\nspiral := b.Spiral(2)  // same as Range but ordered center-outward\n\n// line drawing and visibility\nline := a.Line(b)\nvisible := a.HasLineOfSight(b, blocking)\nfov := a.FieldOfView(candidates, blocking)\n\n// rotation and reflection (cube space)\nrotated := a.Rotate(2)                  // 2×60° clockwise around origin\nrotatedAround := a.RotateAround(b, -1)         // 1×60° counterclockwise around b\nreflectedQ := a.ReflectQ()\nreflectedR := a.ReflectR()\nreflectedS := a.ReflectS()\n\n// directions\ndir := hex.QPlus\nopp := dir.Opposite()             // SPlus\nnext := dir.Rotate(1)             // RMinus (one step counterclockwise)\noffset := dir.NeighborOffset()    // axial vector for this direction\n\n// coordinate system conversions\npOddR := a.To(hex.OffsetOddR)\npEvenQ := a.To(hex.OffsetEvenQ)\ndw := a.To(hex.DoubleWidth)\ndh := a.To(hex.DoubleHeight)\nback := hex.From(pOddR, hex.OffsetOddR)\n\n// pixel-space layout\nlayout := hex.LayoutFlatTop(geom.Sz(16, 16), geom.Pt(100, 80))\ncenter  := layout.ToPoint(a)\nclicked := layout.FromPoint(geom.Pt(499.0, 123.4)).Round()\n```\n\n\n## Credits\n\n- [Tomáš Novotný](https://github.com/tomas-novotny)\n- [All Contributors][link-contributors]\n- [Red Blob Games](https://www.redblobgames.com/grids/hexagons)\n\n\n## License\n\nThe MIT License (MIT). Please see [License File][link-licence] for more information.\n\n\n[ico-license]:              https://img.shields.io/github/license/gravitton/hexagon.svg?style=flat-square\u0026colorB=blue\n[ico-workflow]:             https://img.shields.io/github/actions/workflow/status/gravitton/hexagon/main.yml?branch=main\u0026style=flat-square\n[ico-release]:              https://img.shields.io/github/v/release/gravitton/hexagon?style=flat-square\u0026colorB=blue\n[ico-go-dev-reference]:     https://img.shields.io/badge/go.dev-reference-blue?style=flat-square\n[ico-go-report-card]:       https://goreportcard.com/badge/github.com/gravitton/hexagon?style=flat-square\n[ico-coverage]:             https://img.shields.io/coverallsCoverage/github/gravitton/hexagon?style=flat-square\n\n[link-author]:              https://github.com/gravitton\n[link-release]:             https://github.com/gravitton/hexagon/releases\n[link-contributors]:        https://github.com/gravitton/hexagon/contributors\n[link-licence]:             ./LICENSE.md\n[link-changelog]:           ./CHANGELOG.md\n[link-workflow]:            https://github.com/gravitton/hexagon/actions\n[link-go-dev-reference]:    https://pkg.go.dev/github.com/gravitton/hexagon\n[link-go-report-card]:      https://goreportcard.com/report/github.com/gravitton/hexagon\n[link-coverage]:            https://coveralls.io/github/gravitton/hexagon","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgravitton%2Fhexagon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgravitton%2Fhexagon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgravitton%2Fhexagon/lists"}