Copy() public method

public Copy ( ) : Rectangle
return Rectangle
Ejemplo n.º 1
0
        public TextureInfo(Rectangle region, Rectangle frame, bool rotated)
        {
            if (region != null)
            {
                Region = region.Copy();
            }

            if (frame != null)
            {
                Frame = frame.Copy();
            }

            Rotated = rotated;
        }
Ejemplo n.º 2
0
        protected void Init(Texture texture, Rectangle region = null, Rectangle frame = null, bool rotated = false)
        {
            if (region == null)
                region = new Rectangle(0.0f, 0.0f, texture.Width, texture.Height);

            _parent = texture;
            if (_frame != null)
            {
                _frame = frame.Copy();
            }

            _transformationMatrix = Matrix.Create();
            _width = rotated ? region.Height : region.Width;
            _height = rotated ? region.Width : region.Height;

            if (rotated)
            {
                _transformationMatrix.Translate(0, -1);
                _transformationMatrix.Rotate((float)Math.PI / 2.0f);
            }

            _transformationMatrix.Scale(region.Width / texture.Width, region.Height / texture.Height);

            _transformationMatrix.Translate(region.X / texture.Width, region.Top / texture.Height);
        }