您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

tfn.js 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /**
  2. * Returns an efficient grid for tiling rectangles of the same size and aspect ratio in a rectangular container.
  3. *
  4. * @param {number} ratio - Ratio of the tile's aspect-ratio / the container's aspect-ratio
  5. * @param {number} tilesParam - the number of tiles to calculate the grid for
  6. * @returns {Object} An object containing the number of rows, columns, rows * columns , and tiles
  7. */
  8. // export function calcTileGrid(ratio: number, tilesParam: number) {
  9. function calcTileGrid(ratio, tilesParam) {
  10. let rows = 1;
  11. let columns = 1;
  12. let availableTiles = 1;
  13. let tiles = tilesParam;
  14. // Someone could give you ratio = 0 and/or tiles = Infinity
  15. if (tiles > 65536) {
  16. tiles = 1;
  17. }
  18. while (availableTiles < tiles) {
  19. if ((columns + 1) * ratio < rows + 1) {
  20. columns++;
  21. } else {
  22. rows++;
  23. }
  24. availableTiles = rows * columns;
  25. }
  26. return {
  27. rows,
  28. columns,
  29. availableTiles,
  30. tiles
  31. };
  32. }
  33. function getMaxColumnCount(){
  34. return 5
  35. }
  36. glob_react.fns = glob_react.fns || {}
  37. glob_react.fns.calcTileGrid = calcTileGrid
  38. glob_react.fns.getMaxColumnCount = getMaxColumnCount
  39. glob_react.Filmstrip = glob_react.Filmstrip || {}
  40. glob_react.vidClass = glob_react.vidClass || {prototype:{}}