public void TestBarelyFittingRectangle() {
      SimpleRectanglePacker packer = new SimpleRectanglePacker(128, 128);

      Point placement = packer.Pack(128, 128);

      Assert.AreEqual(new Point(0, 0), placement);
    }
예제 #2
0
        public void TestBarelyFittingRectangle()
        {
            SimpleRectanglePacker packer = new SimpleRectanglePacker(128, 128);

            Point placement = packer.Pack(128, 128);

            Assert.AreEqual(new Point(0, 0), placement);
        }
예제 #3
0
        public void TestThrowOnTooLargeRectangle()
        {
            SimpleRectanglePacker packer = new SimpleRectanglePacker(128, 128);

            Assert.Throws <OutOfSpaceException>(
                delegate() { packer.Pack(129, 129); }
                );
        }
    public void TestTooLargeRectangle() {
      SimpleRectanglePacker packer = new SimpleRectanglePacker(128, 128);
      Point placement;

      bool result = packer.TryPack(129, 10, out placement);
      Assert.IsFalse(result);

      result = packer.TryPack(10, 129, out placement);
      Assert.IsFalse(result);
    }
예제 #5
0
        public void TestTooLargeRectangle()
        {
            SimpleRectanglePacker packer = new SimpleRectanglePacker(128, 128);
            Point placement;

            bool result = packer.TryPack(129, 10, out placement);

            Assert.IsFalse(result);

            result = packer.TryPack(10, 129, out placement);
            Assert.IsFalse(result);
        }
예제 #6
0
 public SpriteFontDoubleColor(GraphicsDevice gdevice,Font font,Color fillcolor,Color bordercolor)
 {
     _font = font;
     _device = gdevice;
     _fillcolor = fillcolor;
     _bordercolor = bordercolor;
     //if (_font.maxcharheight <= 16)
     {
         _tex.Add(new Texture2D(gdevice, 512, 512));
         packer = new SimpleRectanglePacker(512, 512);
     }
     //else
     //{
     //    _tex.Add( new Texture2D(gdevice, 1024, 1024));
     //    packer = new SimpleRectanglePacker(1024, 1024);
     //}
 }
예제 #7
0
        void FillChar(char c)
        {
            if (charposs.ContainsKey(c)) return;
            UInt32[] data;
            var size=
            _font.GetCharData(c,out data);
            Point p;
            var b=packer.TryPack(size.Width, size.Height, out p);
            Texture2D tex;
            if (b)
            {
                charposs[c] = new charpos(
                    new Rectangle(p.X, p.Y, size.Width, size.Height)
                    , _tex.Count - 1
                    );

            }
            else
            {
                //if (_font.maxcharheight <= 16)
                {
                    _tex.Add(new Texture2D(_device, 512, 512));
                    packer = new SimpleRectanglePacker(512, 512);
                }
                //else
                //{
                //    _tex.Add(new Texture2D(_device, 1024, 1024));
                //    packer = new SimpleRectanglePacker(1024, 1024);
                //}
                packer.TryPack(size.Width, size.Height, out p);
                charposs[c] = new charpos(
                    new Rectangle(p.X, p.Y, size.Width, size.Height)
                    , _tex.Count - 1
                    );
            }
            tex = _tex[_tex.Count - 1];
            tex.SetData<UInt32>(0, charposs[c].src, data, 0, data.Length);
        }
예제 #8
0
 public SpriteFontSimple(GraphicsDevice gdevice, Font font)
 {
     _font = font;
     _device = gdevice;
     //if (_font.maxcharheight <= 16)
     {
         _tex.Add(new Texture2D(gdevice, 512, 512));
         packer = new SimpleRectanglePacker(512, 512);
     }
     //else
     //{
     //    _tex.Add(new Texture2D(gdevice, 1024, 1024));
     //    packer = new SimpleRectanglePacker(1024, 1024);
     //}
 }
 public void TestThrowOnTooLargeRectangle() {
   SimpleRectanglePacker packer = new SimpleRectanglePacker(128, 128);
   Assert.Throws<OutOfSpaceException>(
     delegate() { packer.Pack(129, 129); }
   );
 }