public void TestAtlasSecondRowAddRespectsWhitePixelSize() { const int atlas_size = 1024; var atlas = new TextureAtlas(atlas_size, atlas_size); TextureGL texture = atlas.Add(atlas_size - 2 * TextureAtlas.PADDING, 64); RectangleF rect = texture.GetTextureRect(null); Assert.GreaterOrEqual(atlas_size * rect.X, TextureAtlas.PADDING, message: "Texture has insufficient padding"); Assert.GreaterOrEqual(atlas_size * rect.Y, TextureAtlas.WHITE_PIXEL_SIZE + TextureAtlas.PADDING, message: "Texture is placed on top of the white pixel"); }
private void testWithSize(int width, int height) { TextureAtlas atlas = new TextureAtlas(1024, 1024); TextureGL texture = atlas.Add(width, height); if (texture != null) { Assert.AreEqual(texture.Width, width, message: $"Width: {texture.Width} != {width} for texture {width}x{height}"); Assert.AreEqual(texture.Height, height, message: $"Height: {texture.Height} != {height} for texture {width}x{height}"); RectangleF rect = texture.GetTextureRect(null); Assert.LessOrEqual(rect.X + rect.Width, 1, message: $"Returned texture is wider than TextureAtlas for texture {width}x{height}"); Assert.LessOrEqual(rect.Y + rect.Height, 1, message: $"Returned texture is taller than TextureAtlas for texture {width}x{height}"); } else { Assert.True(width > 1024 - TextureAtlas.PADDING * 2 || height > 1024 - TextureAtlas.PADDING * 2 || (width > 1024 - TextureAtlas.PADDING * 2 - TextureAtlas.WHITE_PIXEL_SIZE && height > 1024 - TextureAtlas.PADDING * 2 - TextureAtlas.WHITE_PIXEL_SIZE), message: $"Returned texture is null, but should have fit: {width}x{height}"); } }
public RectangleF GetTextureRect(RectangleF?textureRect = null) { return(TextureGL.GetTextureRect(textureBounds(textureRect))); }