Note that there are some explanatory texts on larger screens.

plurals
  1. POTile (scalable) stacking algorithm
    primarykey
    data
    text
    <p>Here is the problem. I have rectangular canvas that have size of 1. So it have coordinate sistem of (0.0 ... 1.0 - x and 0.0 ... 1.0 - y).</p> <p>I also have some tiles. Tiles are also rectangles. They have diffrent size and amount of tiles is a variable.</p> <p>I want to <strong>stack</strong> tiles in rectangular canvas, from 0.0 to 1.0 (<strong>from left to right, from top to bottom</strong>):</p> <p>1) tiles have to fit in canvas (but fill as much space as they could)</p> <p>2) tiles have to be scaled (if they don't fit), each tile should be scaled by the same amount (they have to remain same proportions).</p> <p>3) imagine that you have this 'tiles' in your hand, and you placing them into this canvas one after another</p> <p>4) it almost like <strong>"TreeMap algorithm"</strong> but - shape of tiles have to be the same (<strong>rectangles</strong>) and <strong>i don't need to fill all space</strong> of canvas</p> <p><img src="https://i.stack.imgur.com/CJWek.png" alt="here is what i want to get"></p> <p><strong>Is there anybody who can show me an algoritm in any C alike language (C, C++, Java, C#)?</strong></p> <p>*I tried this.</p> <p>1) i calculated area of tile, then i calculate a sum of tile's areas (for example: i have two tiles, one have area of 2, other area of 1, them it's mean i have total sum of 3)</p> <p>2) then i calculate what "proportion" each tile have in "total sum of areas" (for example: 2/3 and 1/3)</p> <p>3) then calculate size of rectangle tile by Math.sqrt(x) (for example: Math.sqrt(2/3))</p> <p>4) then draw tile one by one...</p> <p>But this dosen't work always. Sometimes i get tiles to be out of canvas..*</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload