protected override TextureArea CreateTextureArea( TextureArea originalTextureArea, TextureAtlasTextureDefinition definition) { return new CachedTexture( originalTextureArea.TextureId, definition.TopLeft, definition.BottomRight, definition.Width, definition.Height); }
public void Update() { if (_areaNext == null) return; _areaCurrent = _areaNext; _areaNext = null; if (OnChange != null) OnChange(this); }
public TextureArea GetTexture(string filename, Rectangle rectangle) { var newTexture = GetTextureFromCache(filename); // Determine pixel coordinates var topLeft = new Vector { X = rectangle.TopLeft.X / newTexture.Width, Y = rectangle.TopLeft.Y / newTexture.Height }; var bottomRight = new Vector { X = rectangle.BottomRight.X / newTexture.Width, Y = rectangle.BottomRight.Y / newTexture.Height }; var newTextureArea = new TextureArea(newTexture.TextureId, new Vector(topLeft.X, topLeft.Y), new Vector(bottomRight.X, bottomRight.Y)); return newTextureArea; }
/// <summary> /// Load a texture. This texture may be loaded into a texture atlas. /// </summary> /// <param name="filename"></param> /// <returns></returns> public TextureArea GetTexture(string filename) { var cachedTexture = GetTextureFromCache(filename); var newTextureArea = new TextureArea(cachedTexture.TextureId); return newTextureArea; }
private static void WriteQuad(TextureArea texture, Rectangle rect, IDataStream<TransformedColouredTexturedVertex> dataStream, float alpha) { rect = rect.Translate(-0.5f, -0.5f); dataStream.WriteRange( new[] { MakeVertex(rect.TopLeft, texture.AtlasTopLeft, alpha), MakeVertex(rect.BottomRight, texture.AtlasBottomRight, alpha), MakeVertex(rect.BottomLeft, texture.AtlasBottomLeft, alpha), MakeVertex(rect.TopLeft, texture.AtlasTopLeft, alpha), MakeVertex(rect.TopRight, texture.AtlasTopRight, alpha), MakeVertex(rect.BottomRight, texture.AtlasBottomRight, alpha) }); }
private static void WriteCroppedQuad(TextureArea texture, Rectangle rect, IDataStream<TransformedColouredTexturedVertex> dataStream, float horizontalCrop, float verticalCrop) { rect = rect.Translate(-0.5f, -0.5f).Scale(horizontalCrop, verticalCrop); var atlasRect = new Rectangle(texture.AtlasTopLeft, texture.AtlasBottomRight); atlasRect = atlasRect.Scale(horizontalCrop, verticalCrop); dataStream.WriteRange( new[] { MakeVertex(rect.TopLeft, atlasRect.TopLeft), MakeVertex(rect.BottomRight, atlasRect.BottomRight), MakeVertex(rect.BottomLeft, atlasRect.BottomLeft), MakeVertex(rect.TopLeft, atlasRect.TopLeft), MakeVertex(rect.TopRight, atlasRect.TopRight), MakeVertex(rect.BottomRight, atlasRect.BottomRight) }); }
public TextureAreaHolder(TextureArea area) { _areaCurrent = area; _areaNext = null; }
protected abstract TextureArea CreateTextureArea(TextureArea cachedTexture, TextureAtlasTextureDefinition definition);