I’m working on updating my “Simple TMX Library” to be up to the current TMX specs:

I’m pretty close to finished with that work, but there’s one shortcoming. Right now I’m just handling Wang IDs as a plain string and leaving parsing and dealing with that up to the user of the library. But ideally I’d like to add some sort of abstraction so that it’s easier to manipulate it the way Tiled does.

I’ve hit a roadblock with that, though, because I don’t understand what the documentation says about the topic:

The Wang ID, which is a 32-bit unsigned integer stored in the format

`0xCECECECE`

(where each C is a corner color and each E is an edge color, from right to left clockwise, starting with the top edge)

I don’t understand based on this what these 4-bit integers are supposed to refer to. I assume it has to do with and tags, but the only things provided to identify those are names and 24-bit colors, neither of which fit within four bits, so I know it can’t be either of those.

My best guess so far is that maybe these numbers are indexes based on the order the corner and edge tags appear in the wangset. If that’s the case, then my best guess would be to assume that a value of 0 is the first index, 1 is the second index, etc. Could I get some verification on this? I’d like to know if my best guess is right, or if not, what these numbers actually refer to.

EDIT: While I’m at it, I’m also confused by what the documentation means by “from right to left clockwise, starting with the top edge”. Does this mean, going by angles of a circle oriented as in trigonometry: 45-0-315-270-225-180-135-90 (i.e. starting from the top-right and going clockwise)?