示例#1
0
        void CreateBranches(ANTBitmapChar pFTBitmapChar)
        {
            int dx = m_width - pFTBitmapChar.GetWidth();
            int dy = m_height - pFTBitmapChar.GetHeight();

            // we split to give one very small leaf and one very big one
            // because it allows more efficent use of space
            // if you don't do this, the bottom right corner never gets used
            if (dx < dy)
            {
                //	split so the top is cut in half and the rest is one big rect below
                m_Leaf1 = new TreeNode();
                m_Leaf1.Set(m_x + pFTBitmapChar.GetWidth(), m_y,
                            m_width - pFTBitmapChar.GetWidth(),
                            pFTBitmapChar.GetHeight());
                m_Leaf2 = new TreeNode();
                m_Leaf2.Set(m_x, m_y + pFTBitmapChar.GetHeight(),
                            m_width, m_height - pFTBitmapChar.GetHeight());
            }
            else
            {
                //	m_Leaf1 = left (cut in half)
                m_Leaf1 = new TreeNode();
                m_Leaf1.Set(m_x, m_y + pFTBitmapChar.GetHeight(),
                            pFTBitmapChar.GetWidth(), m_height - pFTBitmapChar.GetHeight());
                // m_Leaf2 = right (not cut)
                m_Leaf2 = new TreeNode();
                m_Leaf2.Set(m_x + pFTBitmapChar.GetWidth(), m_y,
                            m_width - pFTBitmapChar.GetWidth(), m_height);
            }
        }
示例#2
0
 bool Fits(ANTBitmapChar pFTBitmapChar)
 {
     return(pFTBitmapChar.GetWidth() <= m_width && pFTBitmapChar.GetHeight() <= m_height);
 }