Giter VIP home page Giter VIP logo

hex-chronicle's People

Contributors

ezian avatar pchesneau avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

hex-chronicle's Issues

Use `shapely.Polygon.svg()` to draw stuff

Context

shapely.Polygon.svg() allow to draw polygon in SVG.

Instead of using template, we should rely on this method, because it will fix issue with zone with hole.

TODO and To take care of

  • Replace render method with version that take advantage of svg() method
  • be careful to make it compatible with css stuff (require to modify the dom, adding classes and removing stuff we don't want)
  • Test with zone with hole (for instance a circular zone 0206 0207 0307 0406 0305 0205 should not cover hex 0306)

Example of return from svg() method

<path fill-rule="evenodd" fill="#66cc99" stroke="#555555" stroke-width="2.0" opacity="0.6"
    d="M 90.0,259.8076211353316 L 120.0,207.84609690826528 L 100.0,173.20508075688775 L 50.0,259.8076211353316 L 90.0,259.8076211353316 z" />

Link to hex file by clicking to an hex

Expected behavior

If I click on an hex in the gird, and if this hex has been generated from a .md file, open a link.

By default, open the file itself.
Possibility to add a link somewhere to make it compatible with Hugo or any static site generator.

Tooltip when hover over an hex

Expected behavior:

When the mouse hover over an hex, open a tooltip which contains some information:

  • Main terrain type
  • Alt text
  • Text contained in the .md filename

Docker packaging

Package the code in a docker container to be more easily used.

Allow custom icon set

Actual behavior

Icons are retrieved from svg_templates/icons. Icon file are selected through metadata in the hex file (the metadata value has to match with at least one icon file).

Allow to pass in command line others directory of icons, which will be fetched to get other icon.

These directories will be fetched before "default" existing directory to retrieve icons. If there is no match, we will still check the default icons.

Users will be allowed to use alternative icon set (by using the same names of existing one), are have new icons (by adding icons with different names)

Terrain optimization

Optimization of the way the terrain is draw:

  • Draw only one polygon for contiguous mixed sides (hex with sea coast) inside a same hex
  • Draw the less number of polygon for contigous type of terrain, over several hex

These optimization may be complicated, but will reduce the size of the SVG AND allow beautiful effect in CSS... Or at least remove ugly artifacts.

Break circular dependency between Hexagon and HexagonGrid

I reviewed usages of self.grid in Hexagon. These are the usages of self.grid:
image

We have 3 values used by Hexagon from HexagonGrid :
For me :

  • Radius and radius2, which are inherent properties of Hexagon and thus could be provided directly at init() time
  • access to icons loaded by HexagonGrid, Could be delegated to ad-hoc context responsible for all drawing operation.

Originally posted by @pchesneau in #12 (comment)

Grid Optimization

The main goal of this issue is to optimize the grid and reduce the size of the SVG file.

Current lead to this goal:

  • Draw Grid polygon as <def> then duplicate through xlink + transform (see [http://thenewcode.com/1102/Cloning-SVG-Elements-Using-use])

Hex icon from terrain

Allow icon from terrain.

The default icon set for terrain is already on the repository, in svg_templates/icons/terrain.

Current behavior

IF a field icon is set in the hex metada with the value <value_icon>
AND an icon file named <value_icon>.svg exists in svg_templates/icons/building
THEN the svg icon in the file is drawed at the top of the hex

Expected behavior

IF a field icon is set in the hex metada with the value <value_icon>
AND an icon file named <value_icon>.svg exists in svg_templates/icons/building
THEN the svg icon in the file <value_icon>.svg is drawed at the top of the hex

**ELSE IF ** a field terrain.type is set in the hex metada with the value <value_terrain_type>
AND an icon file named <value_terrain_type>.svg exists in [svg_templates/icons/terrain]
THEN the svg icon in the file <value_terrain_type>.svg is drawed at the top of the hex

(In english: the terrain icon is drawed if it exists and if there is no building icon that are already required to draw)

Fix and implements negative row or column

Allow to have hexes files with the pattern -XX-YY-somthing.md.

Allowing this pattern is trivial, but the actual compute of the grid contains a bug which botches with negative row or column.

Placeholder file to default some polygons

Actual behavior

Only the polygons defined through a specific XXYY-something.md file will be rendered. It can be painful to define large map with almost nothing.

Expected behavior

Allow user to passe several yaml files which contains description of tiles without MD parts.

Each yaml files can contains several parts splitted as yaml specification (--- characters) and contains a map of values indexed by a string on the "XXYY" format.

Since Yaml can be inlined, it could be easy to quickly define simple hexagons, with full support of all feature, even future one.

Example:

# Careful: 0XXX in YAML spec is an octal number. To avoid confusion, we need to put XXYY coordinates between quotes.
"0705": {"terrain": {"type": "grassland", "mixed":[{"type": "sea", "sides":["NO","SO","NE"}], "roads": ["c SE"], "icon": "fortin", "alt":"Fortin"}
"0806": {"terrain": {"type": "grassland", "mixed":[{"type": "sea", "sides":["N","NE","SE"}], "roads": ["NO NE", "NO S"], "rivers": ["N S", "N SO", "N SE"]}

Above yaml will be equivalent to:

# File 0705-something.md
---
terrain:
    type: grassland
    mixed: 
      - type: sea
        sides:
          - NO
          - SO
          - NE
roads:
  - c SE
icon: fortin
alt: Fortin
---
# File 0806-something.md
---
terrain:
    type: grassland
    mixed: 
      - type: sea
        sides:
          - N
          - NE
          - SE
      - type: plains:
        sides:
          - S
roads:
  - NO NE
  - NO S
rivers: 
  - N S
  - N SO
  - N SE
---

`NO` in yaml frontmatter is handled as `no`, which is `false`

Reproduce

---
terrain:
    type: grassland
    mixed:
        - type: lake
          sides:
            - NO
---

In this case, script will fails and the map won't be generated

How to fix it

Retained solution is to use english cardinal direction (West instead of Ouest). NO will be no more an issue.

But in order to don't require a major update (it's kind of early to update the major version), we shouldn't introduce breaking changes. So Old way to write cardinal should be accepted, but deprecated (generate an error message, but handle it).

Zones

In Oltréé !, the RPG that has inspired this tools, it is possible to "secure" some hex.

In order to be the most generic, we want to have the concept of "zone" embedded in this tools.

Expected functionnality

Zone concept

A zone is a group of hexagon that are bound together.

A zone is drawed at the top of the grid, and contains full hexes.

If two hexes are contiguous and in the same zone, the zone is drawed around them, like in the image below:

image

Zone configuration

A zone is defined as a new field in the file metadata:

zone: secured

It should also have a definition as a class in CSS. In the scope of this issue, we will only define one zone: secured (above css is more for example, I am not a css pro, and I don't have a really good taste in terms of UI design ^^)

.secured {
    stroke: green;
    stroke-dasharray: 8
    fill: greenyellow;
    fill-opacity: 30%;
}

User will be able to add more zone by using custom CSS feature.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.