Exemplo n.º 1
0
        public void DrawImage(DrawImageParams param)
        {
            Microsoft.Xna.Framework.Rectangle? source = null;
            Microsoft.Xna.Framework.Vector2 scaleVector;

            var xnaTexture = (XnaTexture)param.Texture;

            var texture2D = xnaTexture.Texture2D;
            var destinationVector = param.Destination.Location.ToVector2();

            var color = new Color(param.Color.R, param.Color.G, param.Color.B, param.Color.A);
            var rotation = param.Rotation;
            var origin = param.Origin.ToVector2();
            var effect = (SpriteEffects)(int)param.ImageEffect;
            const int Depth = 0;

            if (param.Source.HasValue)
            {
                source = param.Source.Value.ToXnaRect();
                scaleVector = new Vector2(
                    param.Destination.Width / source.Value.Width,
                    param.Destination.Height / source.Value.Height);
            }
            else
            {
                scaleVector = new Vector2(
                    param.Destination.Width / texture2D.Width,
                    param.Destination.Height / texture2D.Height);
            }

            this.spriteBatch.Draw(texture2D, destinationVector, source, color, rotation, origin, scaleVector, effect, Depth);
        }
Exemplo n.º 2
0
 private static DrawImageParams CreateDrawImageParams(RectangleInt source, Vector origin,
     Texture texture = null, Rectangle? destination = null, float rotation = 0.0f, Color? color = null)
 {
     var expected = new DrawImageParams
     {
         Texture = texture,
         Source = source,
         Destination = destination.HasValue ? destination.Value : Rectangle.Empty,
         Rotation = rotation,
         Origin = origin,
         Color = color.HasValue ? color.Value : Color.White,
         ImageEffect = ImageEffect.None
     };
     return expected;
 }
Exemplo n.º 3
0
 private static void AssertDrawImageParamsAreEquals(DrawImageParams expected, DrawImageParams actual)
 {
     Assert.AreEqual(expected.Texture, actual.Texture, "Texture");
     Assert.AreEqual(expected.Source, actual.Source, "Source");
     Assert.AreEqual(expected.Destination, actual.Destination, "Destination");
     Assert.AreEqual(expected.Rotation, actual.Rotation, Epsilon, "Rotation");
     Assert.AreEqual(expected.Origin, actual.Origin, "Origin");
     Assert.AreEqual(expected.Color, actual.Color, "Color");
     Assert.AreEqual(expected.ImageEffect, actual.ImageEffect, "ImageEffect");
 }
Exemplo n.º 4
0
 public void DrawImage(DrawImageParams param)
 {
     this.drawImplementation.DrawImage(param);
 }