Exemple #1
0
        private void letterbox()
        {
            this.scale();

            float scale = (float)TargetSize.X / _image.Texture.Size.X;

            _image.Size  = (Vector2f)_image.Texture.Size;
            _image.Scale = new Vector2f(scale, scale);

            if (_image.GetGlobalBounds().Height > TargetSize.Y)
            {
                scale        = (float)TargetSize.Y / _image.Texture.Size.Y;
                _image.Size  = (Vector2f)_image.Texture.Size;
                _image.Scale = new Vector2f(scale, scale);
            }

            _image.Position = (Vector2f)(GlobalPosition + new Vector2i((int)(TargetSize.X - _image.GetGlobalBounds().Width) / 2, (int)(TargetSize.Y - _image.GetGlobalBounds().Height) / 2));
        }