< Summary - ReFlex - Library

Information
Class: ReFlex.Core.Common.Components.Point2
Assembly: ReFlex.Core.Common
File(s): D:\a\reflex\reflex\library\src\Core\Common\Components\Point2.cs
Line coverage
100%
Covered lines: 20
Uncovered lines: 0
Coverable lines: 20
Total lines: 124
Line coverage: 100%
Branch coverage
100%
Covered branches: 6
Total branches: 6
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_X()100%11100%
get_Y()100%11100%
get_IsValid()100%11100%
.ctor()100%11100%
.ctor(...)100%11100%
.ctor(...)100%11100%
Set(...)100%11100%
Copy()100%11100%
Set(...)100%11100%
Direction(...)100%11100%
Interpolate(...)100%11100%
Equals(...)100%44100%
ToString()100%22100%

File(s)

D:\a\reflex\reflex\library\src\Core\Common\Components\Point2.cs

#LineLine coverage
 1using ReFlex.Core.Common.Interfaces;
 2
 3namespace ReFlex.Core.Common.Components
 4{
 5    /// <summary>
 6    /// A twodimensional point.
 7    /// </summary>
 8    /// <seealso cref="IBase2" />
 9    /// <inheritdoc />
 10    /// <seealso cref="T:ReFlex.Core.Common.Interfaces.IBase2" />
 11    public class Point2 : IBase2
 12    {
 13        /// <inheritdoc />
 14        /// <summary>
 15        /// Gets or sets the x value.
 16        /// </summary>
 17        /// <value>
 18        /// The x value.
 19        /// </value>
 9020        public float X { get; set; }
 21
 22        /// <inheritdoc />
 23        /// <summary>
 24        /// Gets or sets the y value.
 25        /// </summary>
 26        /// <value>
 27        /// The y value.
 28        /// </value>
 8229        public float Y { get; set; }
 30
 31        /// <inheritdoc />
 32        /// <summary>
 33        /// Returns true if ... is valid.
 34        /// </summary>
 35        /// <value>
 36        ///   <c>true</c> if this point is valid; otherwise, <c>false</c>.
 37        /// </value>
 4538        public bool IsValid { get; set; } = true;
 39
 40        /// <summary>
 41        /// Initializes a new instance of the <see cref="Point2"/> class.
 42        /// </summary>
 643        public Point2() => Set(0, 0);
 44
 45        /// <summary>
 46        /// Initializes a new instance of the <see cref="Point2"/> class.
 47        /// </summary>
 48        /// <param name="x">The x.</param>
 49        /// <param name="y">The y.</param>
 3250        public Point2(float x, float y) => Set(x, y);
 51
 52        /// <summary>
 53        /// Initializes a new instance of the <see cref="Point2"/> class.
 54        /// </summary>
 55        /// <param name="base2">The base2.</param>
 656        public Point2(IBase2 base2) => Set(base2);
 57
 58        /// <inheritdoc />
 59        /// <summary>
 60        /// Copies the values from the input to [this] instance.
 61        /// </summary>
 62        /// <param name="base2">The base2.</param>
 463        public void Set(IBase2 base2) => Set(base2.X, base2.Y);
 64
 65        /// <inheritdoc />
 66        /// <summary>
 67        /// Creates a copy of [this].
 68        /// </summary>
 69        /// <returns></returns>
 270        public IBase2 Copy() => new Point2(this);
 71
 72        /// <inheritdoc />
 73        /// <summary>
 74        /// Sets the x and y value.
 75        /// </summary>
 76        /// <param name="x">The x value.</param>
 77        /// <param name="y">The y value.</param>
 78        public void Set(float x, float y)
 2379        {
 2380            X = x;
 2381            Y = y;
 2382        }
 83
 84        /// <summary>
 85        /// Direction from start to end.
 86        /// </summary>
 87        /// <param name="start">The start.</param>
 88        /// <param name="end">The end.</param>
 89        /// <returns>A <see cref="Vector2"/> which points from start to end.</returns>
 90        public static Vector2 Direction(Point2 start, Point2 end) =>
 391            new Vector2(end.X - start.X, end.Y - start.Y);
 92
 93        /// <summary>
 94        /// Interpolates between point1 and point2.
 95        /// </summary>
 96        /// <param name="point1">The point1.</param>
 97        /// <param name="point2">The point2.</param>
 98        /// <param name="weight">The weight.</param>
 99        /// <returns>Interpolated point.</returns>
 100        public static Point2 Interpolate(Point2 point1, Point2 point2, float weight)
 3101        {
 3102            var x = (1 - weight) * point1.X + weight * point2.X;
 3103            var y = (1 - weight) * point1.Y + weight * point2.Y;
 3104            return new Point2(x, y);
 3105        }
 106
 107        /// <inheritdoc />
 108        /// <summary>
 109        /// Equalses the specified base2.
 110        /// </summary>
 111        /// <param name="base2">The base2.</param>
 112        /// <returns></returns>
 14113        public bool Equals(IBase2 base2) => base2 != null && Equals(X, base2.X) && Equals(Y, base2.Y);
 114
 115        /// <summary>
 116        /// Returns a <see cref="string" /> that represents [this] instance.
 117        /// </summary>
 118        /// <returns>
 119        /// A <see cref="string" /> that represents [this] instance.
 120        /// </returns>
 4121        public override string ToString() => IsValid ? $"X: {X}; Y: {Y}" : "invalid";
 122
 123    }
 124}