小编Jak*_*ake的帖子

将N#个正方形调整为尽可能大,同时仍然适合X个Y维的方框.(缩略图!)

我有N个方格.我有一个矩形框.我希望所有的方块都放在盒子里.我希望方块尽可能大.

如何计算方块的最大尺寸,使它们都适合方框?

这是缩略图库中的缩略图.

int function thumbnailSize(
    iItems, // The number of items to fit.
    iWidth, // The width of the container.
    iHeight, // The height of the container.
    iMin // The smallest an item can be.
)
{
    // if there are no items we don't care how big they are!    
    if (iItems = 0) return 0;

    // Max size is whichever dimension is smaller, height or width.
    iDimension = (iWidth min iHeight);

    // Add .49 so that we always …
Run Code Online (Sandbox Code Playgroud)

resize thumbnails aspect-ratio

5
推荐指数
1
解决办法
1422
查看次数

标签 统计

aspect-ratio ×1

resize ×1

thumbnails ×1