zond / godip

A dippy adjudicator in Go.
GNU General Public License v3.0
27 stars 22 forks source link

Render map #178

Closed Wulfheart closed 9 months ago

Wulfheart commented 9 months ago

Related to https://github.com/zond/godip/issues/95

I saw that there is now also a map. How can I render the svg?

zond commented 9 months ago

I'm not sure I understand, are you asking how to get the correct SVG, or how to render it?

Wulfheart commented 9 months ago

Sorry for not phrasing it correctly. Is there a way to generate svg maps using go, not js? If so, how?

zond commented 9 months ago

We only use Go to generate state in the shape of e.g. JSON objects that is then used to render using JS/CSS on WebViews or browsers.

It's a sad truth that SVG is a great format that is only really properly supported by browsers :/

Wulfheart commented 9 months ago

@zond Thank you really much. I think I saw a project which renders them in Python but this massively increases the payload for the client. So rendering it in the browser may actually be beneficial.

One question: How do you calculate where to place the units? I understand that there province-centers and supply centers marked. But how do you calculate the offset? Any suggestions for this?

zond commented 9 months ago

Browser or some kind of WebView, yeah.

We e.g. getElementById('lon_center'), and then use the location of that element as position (with some unit model based offset) for the unit.

Wulfheart commented 9 months ago

Hm. Guess then I am going to do it that way too. Thank you. If I make significant progress I am going to post it here. As you might be interested in it.

Wulfheart commented 9 months ago

Another question, sorry for spamming:

Why is the provinces layer hidden and all provinces are shown when displaying this layer? Currently I am solving this by iterating over all provinces and hide them again if they are not needed but seems a little counterintuitive to me.

zond commented 9 months ago

I don't remember :D