public void Size2dCloneWorks()
        {
            var v = new Size2d(1, 2);
            var v2 = v.Clone();

            v2.Width = 3;

            Assert.NotEqual(v, v2);
            Assert.True(v.Equivalent(new Size2d(1, 2)));
        }
        public void Size2dApplyWorks()
        {
            var v = new Size2d(1.11, 2.22);

            v.Apply(Math.Round);

            Assert.True(v.Equivalent(new Size2d(1, 2)));

            v.Apply(val => { return val + 1; });

            Assert.True(v.Equivalent(new Size2d(2, 3)));
        }
        public void Size2dAddsCorrectly()
        {
            var v = new Size2d(2, 3);

            Assert.False(v == v + 0);
            Assert.False(v == v.Add(0));
            Assert.True(v.Equivalent(v + 0));
            Assert.True(v.Equivalent(v.Add(0)));
            Assert.True((v + v).Equivalent(new Size2d(4, 6)));
            Assert.True(v.Add(v).Equivalent(new Size2d(4, 6)));
            Assert.True((v + .1).Equivalent(new Size2d(2.1, 3.1)));
            Assert.True(v.Add(.1).Equivalent(new Size2d(2.1, 3.1)));
        }
        public void Size2dTriggerWorks()
        {
            var v = new Size2d(2, 3);
            double total = 0;
            Action<double> sum = (val) =>
            {
                total += val;
            };

            v.Trigger(sum);

            Assert.Equal(5, total);
        }
        public void Size2dSubtractsCorrectly()
        {
            var v = new Size2d(2, 3);

            Assert.False(v == v - 0);
            Assert.False(v == v.Subtract(0));
            Assert.False(-v == v.SubtractFrom(0));
            Assert.True(v.Equivalent(v - 0));
            Assert.True(v.Equivalent(v.Subtract(0)));
            Assert.True((-v).Equivalent(0 - v));
            Assert.True((-v).Equivalent(v.SubtractFrom(0)));
            Assert.True((v - v).Equivalent(Size2d.Zero));
            Assert.True((v.Subtract(v)).Equivalent(Size2d.Zero));
            Assert.True((v - .1).Equivalent(new Size2d(1.9, 2.9)));
            Assert.True((v.Subtract(.1)).Equivalent(new Size2d(1.9, 2.9)));
            Assert.True((.1 - v).Equivalent(new Size2d(-1.9, -2.9)));
            Assert.True((v.SubtractFrom(.1)).Equivalent(new Size2d(-1.9, -2.9)));
        }
示例#6
0
 /// <summary>
 /// Returns a Size2d that is the result of subtracting the Width and Height of this Size2d from the Width and Height of a Size2d.
 /// </summary>
 /// <param name="s1">The Size2d to subtract from.</param>
 /// <returns>The result of this Size2d subtracted from the provided Size2d.</returns>
 public Size2d SubtractFrom(Size2d s1)
 {
     return(s1 - this);
 }
示例#7
0
 /// <summary>
 /// Returns a Size2d that is the result of multiplying the Width and Height of this Size2d by the Width and Height of a Size2d.
 /// </summary>
 /// <param name="s1">The Size2d to multiply.</param>
 /// <returns>The result of this Size2d multiplied by the provided Size2d.</returns>
 public Size2d Multiply(Size2d s1)
 {
     return(this * s1);
 }
 /// <summary>
 /// Creates a new instance of BoundingRectangle.
 /// </summary>
 /// <param name="position">Initial Position of the BoundingRectangle.</param>
 /// <param name="size">Initial Size of the BoundingRectangle.</param>
 public BoundingRectangle(Vector2d position, Size2d size) : base(position)
 {
     Size = size;
 }
示例#9
0
 /// <summary>
 /// Returns a Vector2d that is the result of dividing the X and Y of this Vector2d by the Width and Height of the provided Size2d.
 /// </summary>
 /// <param name="val">The Size2d to divide.</param>
 /// <returns>The result of the Vector2d divided by the provided Size2d.</returns>
 public Vector2d Divide(Size2d val)
 {
     return(new Vector2d(X / val.Width, Y / val.Height));
 }
示例#10
0
 /// <summary>
 /// Returns a Vector2d that is the result of subtracting the X and Y of this Vector2d from the Width and Height of the provided Size2d.
 /// </summary>
 /// <param name="val">The Size2d to subtract from.</param>
 /// <returns>The result of the provided Size2d subtracted from this Vector2d.</returns>
 public Vector2d SubtractFrom(Size2d val)
 {
     return(new Vector2d(val.Width - X, val.Height - Y));
 }
示例#11
0
 /// <summary>
 /// Returns a Vector2d that is the result of adding the X and Y of this Vector2d to the Width and Height of the provided Size2d.
 /// </summary>
 /// <param name="val">The Size2d to add.</param>
 /// <returns>The result of this Vector2d added to the provided Size2d.</returns>
 public Vector2d Add(Size2d val)
 {
     return(new Vector2d(X + val.Width, Y + val.Height));
 }
示例#12
0
 /// <summary>
 /// Returns a Vector2d that is the result of dividing the X and Y of this Vector2d by the Width and Height of the provided Size2d.
 /// </summary>
 /// <param name="val">The Size2d to divide.</param>
 /// <returns>The result of the Vector2d divided by the provided Size2d.</returns>
 public Vector2d Divide(Size2d val)
 {
     return new Vector2d(X / val.Width, Y / val.Height);
 }
示例#13
0
 /// <summary>
 /// Returns a Size2d that is the result of multiplying the Width and Height of this Size2d by the Width and Height of a Size2d.
 /// </summary>
 /// <param name="s1">The Size2d to multiply.</param>
 /// <returns>The result of this Size2d multiplied by the provided Size2d.</returns>
 public Size2d Multiply(Size2d s1)
 {
     return this * s1;
 }
示例#14
0
 /// <summary>
 /// Returns a Size2d that is the result of adding the Width and Height of this Size2d to the Width and Height of a Size2d.
 /// </summary>
 /// <param name="s1">The Size2d to add.</param>
 /// <returns>The result of this Size2d added to the provided Size2d.</returns>
 public Size2d Add(Size2d s1)
 {
     return this + s1;
 }
示例#15
0
        public void Size2dMultipliesCorrectly()
        {
            var v = new Size2d(2, 3);

            Assert.False(Size2d.Zero == v * 0);
            Assert.False(Size2d.Zero == v.Multiply(0));
            Assert.True(Size2d.Zero.Equivalent(v * 0));
            Assert.True(Size2d.Zero.Equivalent(v.Multiply(0)));
            Assert.True((v * v).Equivalent(new Size2d(4, 9)));
            Assert.True(v.Multiply(v).Equivalent(new Size2d(4, 9)));
            Assert.True((v * .5).Equivalent(new Size2d(1, 1.5)));
            Assert.True(v.Multiply(.5).Equivalent(new Size2d(1, 1.5)));
        }
示例#16
0
 /// <summary>
 /// Returns a Size2d that is the result of dividing the Width and Height of this Size2d from the Width and Height of a Size2d.
 /// </summary>
 /// <param name="s1">The Size2d to divide</param>
 /// <returns>The result of this Size2d divided from the provided number.</returns>
 public Size2d DivideFrom(Size2d s1)
 {
     return(s1 / this);
 }
示例#17
0
 /// <summary>
 /// Returns a Size2d that is the result of subtracting the Width and Height of this Size2d by the Width and Height of a Size2d.
 /// </summary>
 /// <param name="s1">The Size2d to subtract.</param>
 /// <returns>The result of this Size2d subtracted by the provided number.</returns>
 public Size2d Subtract(Size2d s1)
 {
     return this - s1;
 }
示例#18
0
 /// <summary>
 /// Returns a Size2d that is the result of subtracting the Width and Height of this Size2d from the Width and Height of a Size2d.
 /// </summary>
 /// <param name="s1">The Size2d to subtract from.</param>
 /// <returns>The result of this Size2d subtracted from the provided Size2d.</returns>
 public Size2d SubtractFrom(Size2d s1)
 {
     return s1 - this;
 }
示例#19
0
 /// <summary>
 /// Returns a Vector2d that is the result of dividing the X and Y of this Vector2d from the Width and Height of the provided Size2d.
 /// </summary>
 /// <param name="val">The Vector2d to divide from.</param>
 /// <returns>The result of the Vector2d divided from the provided Size2d.</returns>
 public Vector2d DivideFrom(Size2d val)
 {
     return new Vector2d(val.Width / X, val.Height / Y);
 }
示例#20
0
 /// <summary>
 /// Returns a Size2d that is the result of dividing the Width and Height of this Size2d by the X and Y of a Vector2d.
 /// </summary>
 /// <param name="s1">The Size2d to divide.</param>
 /// <returns>The result of this Size2d divided by the provided Size2d.</returns>
 public Size2d Divide(Size2d s1)
 {
     return this / s1;
 }
示例#21
0
 /// <summary>
 /// Returns a Vector2d that is the result of subtracting the X and Y of this Vector2d by the Width and Height of the provided Size2d.
 /// </summary>
 /// <param name="val">The number to subtract.</param>
 /// <returns>The result of the provided Size2d subtracted from this Vector2d.</returns>
 public Vector2d Subtract(Size2d val)
 {
     return(new Vector2d(X - val.Width, Y - val.Height));
 }
示例#22
0
 /// <summary>
 /// Returns a Size2d that is the result of dividing the Width and Height of this Size2d from the Width and Height of a Size2d.
 /// </summary>
 /// <param name="s1">The Size2d to divide</param>
 /// <returns>The result of this Size2d divided from the provided number.</returns>
 public Size2d DivideFrom(Size2d s1)
 {
     return s1 / this;
 }
示例#23
0
 /// <summary>
 /// Returns a Vector2d that is the result of multiplying the X and Y of this Vector2d by the Width and Height of the provided Size2d.
 /// </summary>
 /// <param name="val">The Size2d to multiply.</param>
 /// <returns>The result of this Vector2d multiplied by the provided Size2d.</returns>
 public Vector2d Multiply(Size2d val)
 {
     return(new Vector2d(X * val.Width, Y * val.Height));
 }
示例#24
0
 /// <summary>
 /// Determines whether this Size2d has the same Width and Height of another Size2d.
 /// </summary>
 /// <param name="s1">The Size2d to compare the current Size2d to.</param>
 /// <returns>Whether the Width and Height of the current Size2d are equivalent to the provided Size2d's.</returns>
 public bool Equivalent(Size2d s1)
 {
     return Width == s1.Width && Height == s1.Height;
 }
示例#25
0
 /// <summary>
 /// Returns a Vector2d that is the result of dividing the X and Y of this Vector2d from the Width and Height of the provided Size2d.
 /// </summary>
 /// <param name="val">The Vector2d to divide from.</param>
 /// <returns>The result of the Vector2d divided from the provided Size2d.</returns>
 public Vector2d DivideFrom(Size2d val)
 {
     return(new Vector2d(val.Width / X, val.Height / Y));
 }
示例#26
0
 /// <summary>
 /// Returns a Vector2d that is the result of adding the X and Y of this Vector2d to the Width and Height of the provided Size2d.
 /// </summary>
 /// <param name="val">The Size2d to add.</param>
 /// <returns>The result of this Vector2d added to the provided Size2d.</returns>
 public Vector2d Add(Size2d val)
 {
     return new Vector2d(X + val.Width, Y + val.Height);
 }
示例#27
0
 /// <summary>
 /// Returns a Size2d that is the result of adding the Width and Height of this Size2d to the Width and Height of a Size2d.
 /// </summary>
 /// <param name="s1">The Size2d to add.</param>
 /// <returns>The result of this Size2d added to the provided Size2d.</returns>
 public Size2d Add(Size2d s1)
 {
     return(this + s1);
 }
示例#28
0
 /// <summary>
 /// Returns a Vector2d that is the result of subtracting the X and Y of this Vector2d by the Width and Height of the provided Size2d.
 /// </summary>
 /// <param name="val">The number to subtract.</param>
 /// <returns>The result of the provided Size2d subtracted from this Vector2d.</returns>
 public Vector2d Subtract(Size2d val)
 {
     return new Vector2d(X - val.Width, Y - val.Height);
 }
示例#29
0
 /// <summary>
 /// Returns a Size2d that is the result of subtracting the Width and Height of this Size2d by the Width and Height of a Size2d.
 /// </summary>
 /// <param name="s1">The Size2d to subtract.</param>
 /// <returns>The result of this Size2d subtracted by the provided number.</returns>
 public Size2d Subtract(Size2d s1)
 {
     return(this - s1);
 }
示例#30
0
 /// <summary>
 /// Returns a Vector2d that is the result of subtracting the X and Y of this Vector2d from the Width and Height of the provided Size2d.
 /// </summary>
 /// <param name="val">The Size2d to subtract from.</param>
 /// <returns>The result of the provided Size2d subtracted from this Vector2d.</returns>
 public Vector2d SubtractFrom(Size2d val)
 {
     return new Vector2d(val.Width - X, val.Height - Y);
 }
示例#31
0
 /// <summary>
 /// Returns a Size2d that is the result of dividing the Width and Height of this Size2d by the X and Y of a Vector2d.
 /// </summary>
 /// <param name="s1">The Size2d to divide.</param>
 /// <returns>The result of this Size2d divided by the provided Size2d.</returns>
 public Size2d Divide(Size2d s1)
 {
     return(this / s1);
 }
示例#32
0
 /// <summary>
 /// Returns a Vector2d that is the result of multiplying the X and Y of this Vector2d by the Width and Height of the provided Size2d.
 /// </summary>
 /// <param name="val">The Size2d to multiply.</param>
 /// <returns>The result of this Vector2d multiplied by the provided Size2d.</returns>
 public Vector2d Multiply(Size2d val)
 {
     return new Vector2d(X * val.Width, Y * val.Height);
 }
示例#33
0
 /// <summary>
 /// Determines whether this Size2d has the same Width and Height of another Size2d.
 /// </summary>
 /// <param name="s1">The Size2d to compare the current Size2d to.</param>
 /// <returns>Whether the Width and Height of the current Size2d are equivalent to the provided Size2d's.</returns>
 public bool Equivalent(Size2d s1)
 {
     return(Width == s1.Width && Height == s1.Height);
 }
示例#34
0
        public void Size2dDividesCorrectly()
        {
            var v = new Size2d(2, 4);

            Assert.False(v == v / 1);
            Assert.False(v == v.Divide(1));
            Assert.True(v.Equivalent(v / 1));
            Assert.True(v.Equivalent(v.Divide(1)));
            Assert.True(new Size2d(.5, .25).Equivalent(1 / v));
            Assert.True(new Size2d(.5, .25).Equivalent(v.DivideFrom(1)));
            Assert.True(new Size2d(20, 40).Equivalent(v / .1));
            Assert.True(new Size2d(20, 40).Equivalent(v.Divide(.1)));
        }