From e5278cf4545c6e68d264667894cdda950e0c27b3 Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Sat, 20 Oct 2007 10:36:27 +0000 Subject: [PATCH] Added ChangeSize function to TexturePacker. --- Source/OpenTK/TexturePacker.cs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Source/OpenTK/TexturePacker.cs b/Source/OpenTK/TexturePacker.cs index 7d37676b..7d39f34d 100644 --- a/Source/OpenTK/TexturePacker.cs +++ b/Source/OpenTK/TexturePacker.cs @@ -76,7 +76,10 @@ namespace OpenTK { Node node; bool found = items.TryGetValue(item, out node); - rect = node.Rect; + if (found) + rect = node.Rect; + else + rect = new Rectangle(); return found; } @@ -95,6 +98,23 @@ namespace OpenTK #endregion + #region public void ChangeSize(int new_width, int new_height) + + /// + /// Changes the dimensions of the TexturePacker surface. + /// + /// The new width of the TexturePacker surface. + /// The new height of the TexturePacker surface. + /// Changing the size of the TexturePacker surface will implicitly call TexturePacker.Clear(). + /// + public void ChangeSize(int new_width, int new_height) + { + Clear(); + root.Rect = new Rectangle(0, 0, new_width, new_height); + } + + #endregion + #region Node class Node