Skip to content
Closed
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
/node_modules
/dist
/coverage
CONTRIBUTING-UPSTREAM.md
40 changes: 40 additions & 0 deletions GRID-NUMBERING-README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Grid Auto-Numbering Implementation Details

**Technical Note:**
As part of my DevOps-focused workflow, I designed the logic and coordinate system for this feature and used Antigravity AI to assist with the specific JavaScript/D3.js implementation.

---

## Logic Overview
The grid numbering system is integrated into the SVG rendering pipeline. It iterates through the existing grid cell data generated by the map engine and overlays a text element for each cell.

### Coordinate System
The system uses a top-down, left-to-right indexing method:
* **Starting Point:** The top-leftmost cell is assigned `0001`.
* **Flow:** Numbers increment horizontally across the row before moving to the next line.
* **Formatting:** Numbers are padded with leading zeros (e.g., `0001`, `0010`, `0100`) to maintain a consistent 4-digit coordinate string, common in tabletop hex-crawl systems.

### Grid Support
The logic dynamically calculates the centroid of each cell to ensure proper label placement regardless of the grid geometry:
* **Pointy Hex:** Centers text within the hexagonal bounds.
* **Square:** Standard center-point alignment.
* **Truncated Square:** Adjusts for the irregular geometry to prevent label clipping.

## Integration Points

### Style Panel
Added a new sub-section under the **Grid** layer in the Style panel:
* **Toggle:** A checkbox to enable/disable the `gridLabels` group in the SVG.
* **Font Size:** A slider controlling the `font-size` attribute of the labels.
* **Color Picker:** A standard hex color input tied to the text `fill` attribute.

### SVG Layering
A new `<g>` element with the ID `#gridLabels` is appended to the main map SVG. It sits directly above the grid lines layer to ensure visibility while remaining below the "Labels" or "Markers" layers.

## Files Modified
* `index.html`: Added the toggle and styling controls to the UI.
* `modules/ui/grid-menu.js`: Logic for handling UI interactions and state.
* `modules/render-grid.js`: Core logic for calculating centroids and appending text elements to the SVG.

## Performance Considerations
For massive maps with thousands of cells, the numbering system is optimized to only render when the Grid layer is active. This prevents unnecessary DOM overhead during standard map navigation.
45 changes: 27 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,38 @@
# Fantasy Map Generator
# Azgaar Fantasy Map Generator - D&D Grid Enhancement

Azgaar's _Fantasy Map Generator_ is a free web application that helps fantasy writers, game masters, and cartographers create and edit fantasy maps.
**Note on Tooling & Accessibility:**
I have mild dyslexia and use LLMs/Antigravity AI as technical prosthetics for writing and implementation. I architect the logic, design the structure, and define the best practices; the AI assists with the Java/JavaScript syntax and grammar formatting. If the documentation style seems overly structured, it is an intentional accessibility choice. I am always the one directing the logic and the "why" behind the code.

Link: [azgaar.github.io/Fantasy-Map-Generator](https://azgaar.github.io/Fantasy-Map-Generator).
---

Refer to the [project wiki](https://github.com/Azgaar/Fantasy-Map-Generator/wiki) for guidance. The current progress is tracked in [Trello](https://trello.com/b/7x832DG4/fantasy-map-generator). Some details are covered in my old blog [_Fantasy Maps for fun and glory_](https://azgaar.wordpress.com).
## Project Overview
This is a personal fork of [Azgaar's Fantasy Map Generator](https://github.com/Azgaar/Fantasy-Map-Generator).

[![preview](https://github.com/Azgaar/Fantasy-Map-Generator/assets/26469650/9502eae9-92e0-4d0d-9f17-a2ba4a565c01)](https://github.com/Azgaar/Fantasy-Map-Generator/assets/26469650/11a42446-4bd5-4526-9cb1-3ef97c868992)
As a long-time DM and SysAdmin/DevOps engineer, I needed a way to reference specific locations during tabletop sessions without manual tagging. This fork adds a **Grid Auto-Numbering** system designed for D&D campaign management and map indexing.

[![preview](https://github.com/Azgaar/Fantasy-Map-Generator/assets/26469650/e751a9e5-7986-4638-b8a9-362395ef7583)](https://github.com/Azgaar/Fantasy-Map-Generator/assets/26469650/e751a9e5-7986-4638-b8a9-362395ef7583)
## Features: Grid Auto-Numbering
This enhancement adds sequential coordinate numbering to grid cells (0001, 0002, 0003, etc.) starting from the top-left of the map.

[![preview](https://github.com/Azgaar/Fantasy-Map-Generator/assets/26469650/b0d0efde-a0d1-4e80-8818-ea3dd83c2323)](https://github.com/Azgaar/Fantasy-Map-Generator/assets/26469650/b0d0efde-a0d1-4e80-8818-ea3dd83c2323)
* **Dynamic Logic:** Numbers align automatically to Pointy Hex, Square, and Truncated Square grids.
* **Style Control:** Font size and color are fully adjustable via the Style panel to ensure readability against different map backgrounds.
* **Integration:** Toggle functionality is built directly into the existing "Grid" layer settings within the Style panel.
* **Documentation:** Technical implementation details and logic can be found in GRID-NUMBERING-README.md.

Join our [Discord server](https://discordapp.com/invite/X7E84HU) and [Reddit community](https://www.reddit.com/r/FantasyMapGenerator) to share your creations, discuss the Generator, suggest ideas and get the most recent updates.
## Local Setup
```bash
# Clone the repository
git clone [https://github.com/rstandow/Fantasy-Map-Generator](https://github.com/rstandow/Fantasy-Map-Generator)
cd Fantasy-Map-Generator

Contact me via [email](mailto:azgaar.fmg@yandex.com) if you have non-public suggestions. For bug reports please use [GitHub issues](https://github.com/Azgaar/Fantasy-Map-Generator/issues) or _#fmg-bugs_ channel on Discord. If you are facing performance issues, please read [the tips](https://github.com/Azgaar/Fantasy-Map-Generator/wiki/Tips#performance-tips).
# Launch
# This is a client-side application. Open index.html in any modern web browser.
```

Pull requests are highly welcomed. The codebase is messy and requires re-design. I will appreciate if you start with minor changes. Check out the [data model](https://github.com/Azgaar/Fantasy-Map-Generator/wiki/Data-model) before contributing.
## Contributing / Upstream
This feature was built to solve a specific table-top gaming need for my own D&D world. If there is interest from the main project or other contributors, I am happy to discuss contributing the grid logic back to the original repository.

You can support the project on [Patreon](https://www.patreon.com/azgaar).
## Credits & License
* **Original Author:** Max Haniyeu (Azgaar) - [Original Repository](https://github.com/Azgaar/Fantasy-Map-Generator)
* **License:** MIT License
* **Fork Enhancements:** rstandow (2024) ( Will continue work on this Late Feb 2026 )

_Inspiration:_

- Martin O'Leary's [_Generating fantasy maps_](https://mewo2.com/notes/terrain)

- Amit Patel's [_Polygonal Map Generation for Games_](http://www-cs-students.stanford.edu/~amitp/game-programming/polygon-map-generation)

- Scott Turner's [_Here Dragons Abound_](https://heredragonsabound.blogspot.com)
1 change: 1 addition & 0 deletions images/fantasy-icons/battlefield.svg
1 change: 1 addition & 0 deletions images/fantasy-icons/bridge.svg
1 change: 1 addition & 0 deletions images/fantasy-icons/brigand.svg
1 change: 1 addition & 0 deletions images/fantasy-icons/burial.svg
1 change: 1 addition & 0 deletions images/fantasy-icons/canoe.svg
1 change: 1 addition & 0 deletions images/fantasy-icons/cave.svg
1 change: 1 addition & 0 deletions images/fantasy-icons/circus.svg
1 change: 1 addition & 0 deletions images/fantasy-icons/dance.svg
1 change: 1 addition & 0 deletions images/fantasy-icons/dungeon.svg
1 change: 1 addition & 0 deletions images/fantasy-icons/encounter.svg
1 change: 1 addition & 0 deletions images/fantasy-icons/fair.svg
1 change: 1 addition & 0 deletions images/fantasy-icons/forest.svg
1 change: 1 addition & 0 deletions images/fantasy-icons/hot-spring.svg
1 change: 1 addition & 0 deletions images/fantasy-icons/inn.svg
1 change: 1 addition & 0 deletions images/fantasy-icons/joust.svg
1 change: 1 addition & 0 deletions images/fantasy-icons/library.svg
1 change: 1 addition & 0 deletions images/fantasy-icons/lighthouse.svg
1 change: 1 addition & 0 deletions images/fantasy-icons/migration.svg
1 change: 1 addition & 0 deletions images/fantasy-icons/mine.svg
1 change: 1 addition & 0 deletions images/fantasy-icons/mirage.svg
1 change: 1 addition & 0 deletions images/fantasy-icons/monster.svg
1 change: 1 addition & 0 deletions images/fantasy-icons/necropolis.svg
1 change: 1 addition & 0 deletions images/fantasy-icons/pirate.svg
15 changes: 15 additions & 0 deletions images/fantasy-icons/placeholder.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/fantasy-icons/portal.svg
1 change: 1 addition & 0 deletions images/fantasy-icons/rift.svg
1 change: 1 addition & 0 deletions images/fantasy-icons/ruins.svg
1 change: 1 addition & 0 deletions images/fantasy-icons/sacred-mountain.svg
1 change: 1 addition & 0 deletions images/fantasy-icons/sea-monster.svg
1 change: 1 addition & 0 deletions images/fantasy-icons/statue.svg
1 change: 1 addition & 0 deletions images/fantasy-icons/volcano.svg
1 change: 1 addition & 0 deletions images/fantasy-icons/water-source.svg
1 change: 1 addition & 0 deletions images/fantasy-icons/waterfall.svg
1 change: 1 addition & 0 deletions index.css
Original file line number Diff line number Diff line change
Expand Up @@ -2421,3 +2421,4 @@ svg.button {
background: #25252a;
}
}
.grid-label { font-size: 10px; font-family: sans-serif; pointer-events: none; text-shadow: 1px 1px 0 #fff, -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff; }
Loading