mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-10 16:49:09 +01:00
35 lines
1.3 KiB
C#
35 lines
1.3 KiB
C#
using System.Linq;
|
|
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using MLEM.Data;
|
|
using MLEM.Textures;
|
|
using NUnit.Framework;
|
|
|
|
namespace Tests {
|
|
public class TestDataTextureAtlas {
|
|
|
|
[Test]
|
|
public void Test() {
|
|
using var game = TestGame.Create();
|
|
using var texture = new Texture2D(game.GraphicsDevice, 1, 1);
|
|
var atlas = DataTextureAtlas.LoadAtlasData(new TextureRegion(texture), game.RawContent, "Texture.atlas");
|
|
Assert.AreEqual(atlas.Regions.Count(), 8);
|
|
|
|
// no added offset
|
|
var table = atlas["LongTableUp"];
|
|
Assert.AreEqual(table.Area, new Rectangle(0, 32, 64, 48));
|
|
Assert.AreEqual(table.PivotPixels, new Vector2(16, 48 - 32));
|
|
|
|
// added offset
|
|
var table2 = atlas["LongTableLeft"];
|
|
Assert.AreEqual(table2.Area, new Rectangle(64, 32, 64, 48));
|
|
Assert.AreEqual(table2.PivotPixels, new Vector2(112 - 64, 48 - 32));
|
|
|
|
// negative pivot
|
|
var negativePivot = atlas["TestRegionNegativePivot"];
|
|
Assert.AreEqual(negativePivot.Area, new Rectangle(0, 32, 16, 16));
|
|
Assert.AreEqual(negativePivot.PivotPixels, new Vector2(-32, 46 - 32));
|
|
}
|
|
|
|
}
|
|
}
|