/// <summary> /// Creates a blank texture you can use. Libvaxy will automatically dispose this texture on unload. /// </summary> /// <param name="width">The width of the texture.</param> /// <param name="height">The height of the texture.</param> /// <returns>The newly created texture.</returns> public static Texture2D CreateTexture(int width, int height) { Texture2D texture = new Texture2D(Main.graphics.GraphicsDevice, width, height); LibvaxyMod.DisposeOnUnload(texture); return(texture); }
/// <summary> /// Clones a certain rectangle within a texture and returns a new Texture2D object for it. Libvaxy will automatically dispose the cloned texture on unload. /// </summary> /// <param name="rect">The rectangle within the texture to clone.</param> /// <returns>The cloned texture rectangle.</returns> public static Texture2D CloneRectangle(this Texture2D texture, Rectangle rect) { Texture2D newTexture = new Texture2D(Main.instance.GraphicsDevice, rect.Width, rect.Height); Color[] colors = texture.GetColorsRect(rect); newTexture.SetData(colors); LibvaxyMod.DisposeOnUnload(newTexture); return(newTexture); }
/// <summary> /// Clones a certain texture and returns a new Texture2D object for it. Libvaxy will automatically dispose the cloned texture on unload. /// </summary> /// <returns>The cloned texture.</returns> public static Texture2D Clone(this Texture2D texture) { Color[] colors = texture.GetColors(); Texture2D newTexture = new Texture2D(Main.instance.GraphicsDevice, texture.Width, texture.Height); newTexture.SetData(colors); LibvaxyMod.DisposeOnUnload(newTexture); return(newTexture); }