Пример #1
0
        IBlockSet <IBlock> Merge(IBlockSet <IBlock> b1, IBlockSet <IBlock> b2)
        {
            bool  first = b1.GetX() < b2.GetX();
            float x1    = Math.Min(b1.GetX(), b2.GetX());
            float x2    = Math.Max(b1.GetX() + b1.GetWidth(), b2.GetX() + b2.GetWidth());
            float h1    = Math.Min(b1.GetH(), b2.GetH());
            float h2    = Math.Max(b1.GetH() + b1.GetHeight(), b2.GetH() + b2.GetHeight());

            var blocks = (first) ? b1.Concat(b2) : b2.Concat(b1);

            var newblock = new BlockSet2 <IBlock>(blocks, x1, h1, x2, h2);

            return(newblock);
        }
Пример #2
0
        IBlockSet <IBlock> ResizeBlockSet(IBlockSet <IBlock> bset, float minX, float maxX)
        {
            float maxWidth     = maxX - minX;
            float width        = bset.GetWidth();
            bool  shouldResize = Math.Abs(maxWidth - width) > WIDTH_DIFFERENCE;

            float x1 = Math.Min(minX, bset.GetX());
            float x2 = Math.Max(maxX, bset.GetX() + bset.GetWidth());
            float h1 = bset.GetH();
            float h2 = bset.GetH() + bset.GetHeight();

            if (shouldResize)
            {
                return(new BlockSet2 <IBlock>(bset, x1, h1, x2, h2));
            }

            return(bset);
        }