#region License
/* FNA - XNA4 Reimplementation for Desktop Platforms
* Copyright 2009-2016 Ethan Lee and the MonoGame Team
*
* Released under the Microsoft Public License.
* See LICENSE for details.
*/
/* Derived from code by the Mono.Xna Team (Copyright 2006).
* Released under the MIT License. See monoxna.LICENSE for details.
*/
#endregion
#region Using Statements
using System;
#endregion
namespace Microsoft.Xna.Framework
{
///
/// Key point on the .
///
[Serializable]
public class CurveKey : IEquatable, IComparable
{
#region Public Properties
///
/// Gets or sets the indicator whether the segment between this point and the next point on the curve is discrete or continuous.
///
public CurveContinuity Continuity
{
get;
set;
}
///
/// Gets a position of the key on the curve.
///
public float Position
{
get;
private set;
}
///
/// Gets or sets a tangent when approaching this point from the previous point on the curve.
///
public float TangentIn
{
get;
set;
}
///
/// Gets or sets a tangent when leaving this point to the next point on the curve.
///
public float TangentOut
{
get;
set;
}
///
/// Gets a value of this point.
///
public float Value
{
get;
set;
}
#endregion
#region Public Constructors
///
/// Creates a new instance of class.
///
/// Position on the curve.
/// Value of the control point.
public CurveKey(
float position,
float value
) : this(
position,
value,
0,
0,
CurveContinuity.Smooth
) {
}
///
/// Creates a new instance of class.
///
/// Position on the curve.
/// Value of the control point.
/// Tangent approaching point from the previous point on the curve.
/// Tangent leaving point toward next point on the curve.
public CurveKey(
float position,
float value,
float tangentIn,
float tangentOut
) : this(
position,
value,
tangentIn,
tangentOut,
CurveContinuity.Smooth
) {
}
///
/// Creates a new instance of class.
///
/// Position on the curve.
/// Value of the control point.
/// Tangent approaching point from the previous point on the curve.
/// Tangent leaving point toward next point on the curve.
/// Indicates whether the curve is discrete or continuous.
public CurveKey(
float position,
float value,
float tangentIn,
float tangentOut,
CurveContinuity continuity
) {
Position = position;
Value = value;
TangentIn = tangentIn;
TangentOut = tangentOut;
Continuity = continuity;
}
#endregion
#region Public Methods
///
/// Creates a copy of this key.
///
/// A copy of this key.
public CurveKey Clone()
{
return new CurveKey(
Position,
Value,
TangentIn,
TangentOut,
Continuity
);
}
public int CompareTo(CurveKey other)
{
return Position.CompareTo(other.Position);
}
public bool Equals(CurveKey other)
{
return (this == other);
}
#endregion
#region Public Static Operators and Override Methods
///
/// Compares whether two instances are not equal.
///
/// instance on the left of the not equal sign.
/// instance on the right of the not equal sign.
/// true if the instances are not equal; false otherwise.
public static bool operator !=(CurveKey a, CurveKey b)
{
return !(a == b);
}
///
/// Compares whether two instances are equal.
///
/// instance on the left of the equal sign.
/// instance on the right of the equal sign.
/// true if the instances are equal; false otherwise.
public static bool operator ==(CurveKey a, CurveKey b)
{
if (object.Equals(a, null))
{
return object.Equals(b, null);
}
if (object.Equals(b, null))
{
return object.Equals(a, null);
}
return ( (a.Position == b.Position) &&
(a.Value == b.Value) &&
(a.TangentIn == b.TangentIn) &&
(a.TangentOut == b.TangentOut) &&
(a.Continuity == b.Continuity) );
}
public override bool Equals(object obj)
{
return (obj as CurveKey) == this;
}
public override int GetHashCode()
{
return (
Position.GetHashCode() ^
Value.GetHashCode() ^
TangentIn.GetHashCode() ^
TangentOut.GetHashCode() ^
Continuity.GetHashCode()
);
}
#endregion
}
}