dongwai4434 2010-02-03 04:50 采纳率: 0%
浏览 23
已采纳

绘制锦标赛支架(PHP&GD)

I'm currently working on drawing a tournament bracket for one of my projects. It seems to be working drawing smaller brackets but once I get to 16 it starts acting up.

Follow through the links, and see how it falls out of place after 8.

http://www.mattdsworld.com/mmaplayer/index.php/tournament/viewBracket/2

http://www.mattdsworld.com/mmaplayer/index.php/tournament/viewBracket/4

http://www.mattdsworld.com/mmaplayer/index.php/tournament/viewBracket/8

http://www.mattdsworld.com/mmaplayer/index.php/tournament/viewBracket/16

http://www.mattdsworld.com/mmaplayer/index.php/tournament/viewBracket/32

http://www.mattdsworld.com/mmaplayer/index.php/tournament/viewBracket/64

http://www.mattdsworld.com/mmaplayer/index.php/tournament/viewBracket/128

After that I get out of ram errors, which isn't really an issue since its legitimate use of ram, and I can justify raising the maximums for this script (of course, it won't run every page load in the final script,the image will be cached).

Anyways, As you can see if you progress through the images, they seem to get more and more off track.

The code is here: http://pastebin.com/f5485b027 (should I be posting code like this, or inline? I wasn't sure)

I am completely lost as to how to fix this, so please input ideas/suggestions. I don't need a code solution, I just need guidance on the math/positioning.

Thanks, Matt

  • 写回答

1条回答 默认 最新

  • duanbarong4617 2010-02-03 05:43
    关注

    The brackets are "correctly" drawn based on the algorithm.

    Did you step through the code for the problem cases especially for $y?

    i'm not sure how the algo works (don't really understand the use of the $takeAway).

    But this is what i would come up with:

    for ($k = 1; $k < ($rounds + 1); $k++)
    {
        // Calculate currLeftDraw and currRightDraw Here...
    
        $spacing = 60 * pow(2, ($k - 1));
        $firstY = ($spacing / 2) - 30;
    
        for ($i = 0; $i < ($sizePlayers / (pow(2, $k))); $i++)
        {
            $yPos = $firstY + ($i * $spacing);
    
            // Rest of code here...
        }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序