Example #1
0
 /// <summary>
 ///     Pushes the edges of the <see cref="FarRectangle"/> out by the horizontal and vertical values specified.
 /// </summary>
 /// <param name="horizontalAmount">Value to push the sides out by.</param>
 /// <param name="verticalAmount">Value to push the top and bottom out by.</param>
 public void Inflate(float horizontalAmount, float verticalAmount)
 {
     X      -= horizontalAmount;
     Y      -= verticalAmount;
     Width  += horizontalAmount + horizontalAmount;
     Height += verticalAmount + verticalAmount;
 }
Example #2
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="FarRectangle"/> struct.
 /// </summary>
 /// <param name="x">The x-coordinate of the rectangle.</param>
 /// <param name="y">The y-coordinate of the rectangle.</param>
 /// <param name="width">The width of the rectangle.</param>
 /// <param name="height">The height of the rectangle.</param>
 public FarRectangle(int x, int y, int width, int height)
 {
     X      = x;
     Y      = y;
     Width  = width;
     Height = height;
 }
Example #3
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="FarRectangle"/> struct.
 /// </summary>
 /// <param name="x">The x-coordinate of the rectangle.</param>
 /// <param name="y">The y-coordinate of the rectangle.</param>
 /// <param name="width">The width of the rectangle.</param>
 /// <param name="height">The height of the rectangle.</param>
 public FarRectangle(float x, float y, float width, float height)
 {
     X      = x;
     Y      = y;
     Width  = width;
     Height = height;
 }
Example #4
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="FarRectangle"/> struct.
 /// </summary>
 /// <param name="x">The x-coordinate of the rectangle.</param>
 /// <param name="y">The y-coordinate of the rectangle.</param>
 /// <param name="width">The width of the rectangle.</param>
 /// <param name="height">The height of the rectangle.</param>
 public FarRectangle(FarValue x, FarValue y, float width, float height)
 {
     X      = x;
     Y      = y;
     Width  = width;
     Height = height;
 }
Example #5
0
        /// <summary>
        ///     Performs a <see href="https://en.wikipedia.org/wiki/Smoothstep"/>
        ///     interpolation between the specified values.
        /// </summary>
        /// <param name="value1">The value to interpolate from.</param>
        /// <param name="value2">The value to interpolate towards.</param>
        /// <param name="amount">The amount to interpolate.</param>
        /// <returns>The interpolated value.</returns>
        public static FarPosition SmoothStep(FarPosition value1, FarPosition value2, float amount)
        {
            FarPosition result;

            FarValue.SmoothStep(ref value1.X, ref value2.X, amount, out result.X);
            FarValue.SmoothStep(ref value1.Y, ref value2.Y, amount, out result.Y);
            return(result);
        }
Example #6
0
        /// <summary>Clamps the specified value between the specified minimum and maximum.</summary>
        /// <param name="value">The value to clamp.</param>
        /// <param name="min">The minimum of the interval to clamp to.</param>
        /// <param name="max">The maximum of the interval to clamp to.</param>
        /// <returns>The clamped value.</returns>
        public static FarPosition Clamp(FarPosition value, FarPosition min, FarPosition max)
        {
            FarPosition result;

            FarValue.Clamp(ref value.X, ref min.X, ref max.X, out result.X);
            FarValue.Clamp(ref value.Y, ref min.Y, ref max.Y, out result.Y);
            return(result);
        }
Example #7
0
 /// <summary>Reads a far value.</summary>
 /// <param name="packet">The packet to read from.</param>
 /// <param name="data">The read value.</param>
 /// <returns>This packet, for call chaining.</returns>
 /// <exception cref="PacketException">The packet has not enough available data for the read operation.</exception>
 public static IReadablePacket Read(this IReadablePacket packet, out FarValue data)
 {
     data = packet.ReadFarValue();
     return(packet);
 }
Example #8
0
 /// <summary>Writes the specified far value.</summary>
 /// <param name="packet">The packet to write to.</param>
 /// <param name="data">The value to write.</param>
 /// <returns>This packet, for call chaining.</returns>
 public static IWritablePacket Write(this IWritablePacket packet, FarValue data)
 {
     return(packet.Write(data.Segment).Write(data.Offset));
 }
Example #9
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="FarPosition"/> struct.
 /// </summary>
 /// <param name="xy">The x- and y-coordinate of the position.</param>
 public FarPosition(FarValue xy)
 {
     X = xy;
     Y = xy;
 }
Example #10
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="FarPosition"/> struct.
 /// </summary>
 /// <param name="x">The x-coordinate of the position.</param>
 /// <param name="y">The y-coordinate of the position.</param>
 public FarPosition(FarValue x, FarValue y)
 {
     X = x;
     Y = y;
 }
Example #11
0
 /// <summary>
 ///     Performs a <see href="https://en.wikipedia.org/wiki/Smoothstep"/>
 ///     interpolation between the specified values.
 /// </summary>
 /// <param name="value1">The value to interpolate from.</param>
 /// <param name="value2">The value to interpolate towards.</param>
 /// <param name="amount">The amount to interpolate.</param>
 /// <param name="result">The interpolated value.</param>
 public static void SmoothStep(
     ref FarPosition value1, ref FarPosition value2, float amount, out FarPosition result)
 {
     FarValue.SmoothStep(ref value1.X, ref value2.X, amount, out result.X);
     FarValue.SmoothStep(ref value1.Y, ref value2.Y, amount, out result.Y);
 }
Example #12
0
 /// <summary>Clamps the specified value between the specified minimum and maximum.</summary>
 /// <param name="value">The value to clamp.</param>
 /// <param name="min">The minimum of the interval to clamp to.</param>
 /// <param name="max">The maximum of the interval to clamp to.</param>
 /// <param name="result">The clamped value.</param>
 public static void Clamp(
     ref FarPosition value, ref FarPosition min, ref FarPosition max, out FarPosition result)
 {
     FarValue.Clamp(ref value.X, ref min.X, ref max.X, out result.X);
     FarValue.Clamp(ref value.Y, ref min.Y, ref max.Y, out result.Y);
 }
Example #13
0
 /// <summary>
 ///     Changes the position of the <see cref="FarRectangle"/>.
 /// </summary>
 /// <param name="offsetX">Change in the x-position.</param>
 /// <param name="offsetY">Change in the y-position.</param>
 public void Offset(float offsetX, float offsetY)
 {
     X += offsetX;
     Y += offsetY;
 }
Example #14
0
 /// <summary>
 ///     Changes the position of the <see cref="FarRectangle"/>.
 /// </summary>
 /// <param name="amount">
 ///     The value to adjust the position of the <see cref="FarRectangle"/> by.
 /// </param>
 public void Offset(Vector2 amount)
 {
     X += amount.X;
     Y += amount.Y;
 }
Example #15
0
 /// <summary>
 ///     Changes the position of the <see cref="FarRectangle"/>.
 /// </summary>
 /// <param name="amount">
 ///     The value to adjust the position of the <see cref="FarRectangle"/> by.
 /// </param>
 public void Offset(FarPosition amount)
 {
     X += amount.X;
     Y += amount.Y;
 }