0
votes

I would like to create a tilesource for OpenSeadragon, to render a player's view for a game. The world has coordinates (x,y), player is on a particular coord, with a view range.

What I would like is to create a tilesource for OpenSeadragon, that can display the whole view. At maximum zoom, 1 tile = 1 coord. So I have a few questions : How can I compute the maximum zoomlevel for player's view range ? How can I know the world positions I have to render in the tile that is requested by OpenSeadragon (x, y, level) ?

Thanks :)

1
Do the game graphics change over time? Do you want the user limited to only a section of the board?iangilman
Graphics can change over time, but it is not live on player's browser (not yet, maybe a long time later). For now it is juste a generated static bitmap (like if I generate a big bitmap of players view).Dede
Player will be limited to view only his own sight, that can change. (but if so, it will trigger a view refresh)Dede

1 Answers

1
votes

If I understand correctly, you're trying to create a custom TileSource where you can load from a set of standard tiles that make up the building blocks of your game map. If you want, you can specify that the max level is the only level it tries to load (by making minLevel and maxLevel the same), so you don't have to deal with generating tile combinations. That makes getTileUrl(level, x, y) easy, since you only have to deal with the 1:1 layer. This leaves the question of what is that max level. As defined in:

http://openseadragon.github.io/docs/OpenSeadragon.TileSource.html

...the formula is:

By default the image pyramid is split into N layers where the images longest side in M (in pixels), where N is the smallest integer which satisfies 2^(N+1) >= M.

Basically you're just counting powers of 2 until you get to the size of your image. So, if your image is 1 pixel on a side, your max level is 0. If it's 2 pixels on a side, your max level is 1, 4 = 2, 8 = 3, etc.

Let's say your tileSize is 100 pixels and the map is 5x7 tiles. This means the longest dimension is 700 pixels. Looking at powers of 2, 700 is bigger than 512 and smaller than 1024, so we use 1024. 1024 is the 10th power of 2, so your max level is 10.

Does that answer your questions?