示例#1
0
 /// <summary>
 ///     Given an existing <see cref="VirtualTexture2D"/> instance, creates a new
 ///     <see cref="VirtualTexture2D"/> from the parent based on the rectanglur boundry
 ///     given.
 /// </summary>
 /// <param name="instance">
 ///     The existing <see cref="VirtualTexture2D"/> to based this one on.
 /// </param>
 /// <param name="x">
 ///     The top-left x-coordinate of the boundry within the existing. <see cref="VirtualTexture2D"/>
 ///     to create this one from.
 /// </param>
 /// <param name="y">
 ///     The top-left y-coordinate of the boundry within the existing <see cref="VirtualTexture2D"/>
 ///     to create this one from.
 /// </param>
 /// <param name="width">
 ///     The width of the boundry within the existing <see cref="VirtualTexture2D"/> to create
 ///     this one from.
 /// </param>
 /// <param name="height">
 ///     The height of the boundry within the existing <see cref="VirtualTexture2D"/> to create
 ///     this one from.
 /// </param>
 public VirtualTexture2D(VirtualTexture2D instance, int x, int y, int width, int height)
 {
     Texture    = instance.Texture;
     ClipRect   = instance.GetRelativeRect(x, y, width, height);
     DrawOffset = new Vector2(-Math.Min(x - instance.DrawOffset.X, 0), -Math.Min(y - instance.DrawOffset.Y, 0));
     Width      = width;
     Height     = height;
     SetUtil();
 }
示例#2
0
        /// <summary>
        ///     Given the top-left xy-coordinate and the width and height of a rectanglur boundry within this
        ///     <see cref="VirtualTexture2D"/>, creates and returns a new <see cref="VirtualTexture2D"/>
        ///     instance based on the boudnry area.
        /// </summary>
        /// <param name="x">
        ///     The top-left x-coordinate of the boundry area withn this <see cref="VirtualTexture2D"/>.
        /// </param>
        /// <param name="y">
        ///     The top-left y-coordinate of the boundry area within this <see cref="VirtualTexture2D"/>.
        /// </param>
        /// <param name="width">
        ///     The width of the boundry area within this <see cref="VirtualTexture2D"/>.
        /// </param>
        /// <param name="height">
        ///     The height of the boundry area within this <see cref="VirtualTexture2Dl"/>.
        /// </param>
        /// <param name="applyTo">
        ///     If provided, the new <see cref="VirtualTexture2D"/> instance that is created is instead
        ///     applied to this exisitng instance; otherwise a new instance is created.
        /// </param>
        /// <returns>
        ///     The <see cref="VirtualTexture2D"/> instance that represents the subtexture region of this
        ///     instance within the boundry given.
        /// </returns>
        public VirtualTexture2D GetSubTexture(int x, int y, int width, int height, VirtualTexture2D applyTo = null)
        {
            if (applyTo == null)
            {
                return(new VirtualTexture2D(this, x, y, width, height));
            }

            applyTo.Texture    = Texture;
            applyTo.ClipRect   = GetRelativeRect(x, y, width, height);
            applyTo.DrawOffset = new Vector2(-Math.Min(x - DrawOffset.X, 0), -Math.Min(y - DrawOffset.Y, 0));
            applyTo.Width      = width;
            applyTo.Height     = height;

            return(applyTo);
        }
示例#3
0
 /// <summary>
 ///     Given the rectangluar boundry within this <see cref="VirtualTexture2D"/>, creates and returns a
 ///     new <see cref="VirtualTexture2D"/> instance based on the boundry area.
 /// </summary>
 /// <param name="boundry">
 ///     The rectangluar boundy within this <see cref="VirtualTexture2D"/>.
 /// </param>
 /// <param name="applyTo">
 ///     If provided, the new <see cref="VirtualTexture2D"/> instance that is created is instead
 ///     applied to this existing instance; otherwise a new instance is created.
 /// </param>
 /// <returns>
 ///     The <see cref="VirtualTexture2D"/> instance that represents the subtexture region of this
 ///     instance within the boundry given.
 /// </returns>
 public VirtualTexture2D GetSubTexture(Rectangle boundry, VirtualTexture2D applyTo = null)
 {
     return(GetSubTexture(boundry.X, boundry.Y, boundry.Width, boundry.Height, applyTo));
 }
示例#4
0
 /// <summary>
 ///     Given the top-left xy-coordinate location, and the size of a rectanglur boundry within this
 ///     <see cref="VirtualTexture2D"/>, creates a nd returns a new <see cref="VirtualTexture2D"/>
 ///     instances based on the boundry area.
 /// </summary>
 /// <param name="location">
 ///     The top-left xy-coordinate location of the boundry within this <see cref="VirtualTexture2D"/>.
 /// </param>
 /// <param name="size">
 ///     The width and height of the boundry within this <see cref="VirtualTexture2D"/>.
 /// </param>
 /// <param name="applyTo">
 ///     If provieded, the new <see cref="VirtualTexture2D"/> instance that is created is instead
 ///     applied to this existing instance; otherwise a new instance is created.
 /// </param>
 /// <returns>
 ///     The <see cref="VirtualTexture2D"/> instance that represents the subtexture region of this
 ///     instance within the boundry given.
 /// </returns>
 public VirtualTexture2D GetSubTexture(Point location, Size size, VirtualTexture2D applyTo = null)
 {
     return(GetSubTexture(location.X, location.Y, size.Width, size.Height, applyTo));
 }
示例#5
0
 /// <summary>
 ///     Given an exisitng <see cref="VirtualTexture2D"/> instance, create a new one based on
 ///     a rectangluar boundry within the existing one.
 /// </summary>
 /// <param name="instance">
 ///     The existing <see cref="VirtualTexture2D"/> instance to create this one from.
 /// </param>
 /// <param name="clipRect">
 ///     The rectangluar boundry within the existing instance to create this one from.
 /// </param>
 public VirtualTexture2D(VirtualTexture2D instance, Rectangle clipRect)
     : this(instance, clipRect.X, clipRect.Y, clipRect.Width, clipRect.Height)
 {
 }
示例#6
0
 /// <summary>
 ///     Given the content relative path to a Texture2D asset, loads the asset
 ///     and sets the VirtualTexture2D property of this component, then returns
 ///     thsi componennt.
 /// </summary>
 /// <param name="contentPath">
 ///     The path to the Texture2D asset to load relative to the Content root directory.
 /// </param>
 /// <returns>
 ///     This component instance.
 /// </returns>
 public virtual SpriteComponent SetTexture(string contentPath)
 {
     VirtualTexture = VirtualTexture2D.FromContent(contentPath);
     return(this);
 }
示例#7
0
 /// <summary>
 ///     Given a VirtualTexture2D, sets it as the texture for this component and
 ///     returns the component back.
 /// </summary>
 /// <param name="virtualTexture">
 ///     The VirtualTexture2D to set.
 /// </param>
 /// <returns>
 ///     This component instance.
 /// </returns>
 public virtual SpriteComponent SetTexture(VirtualTexture2D virtualTexture)
 {
     VirtualTexture = virtualTexture;
     return(this);
 }
示例#8
0
 /// <summary>
 ///     Creates a new SpriteComponent instnace.
 /// </summary>
 /// <param name="virtualTexture">
 ///     The VirtualTexture to use when rendering.
 /// </param>
 public SpriteComponent(VirtualTexture2D virtualTexture) : base()
 {
     VirtualTexture = virtualTexture;
 }