< Summary

Information
Class: FixedMathSharp.FixedCurveKey
Assembly: FixedMathSharp
File(s): /home/runner/work/FixedMathSharp/FixedMathSharp/src/FixedMathSharp/Numerics/FixedCurveKey.cs
Line coverage
100%
Covered lines: 21
Uncovered lines: 0
Coverable lines: 21
Total lines: 94
Line coverage: 100%
Branch coverage
100%
Covered branches: 8
Total branches: 8
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
.ctor(...)100%11100%
.ctor(...)100%11100%
.ctor(...)100%11100%
Equals(...)100%66100%
Equals(...)100%22100%
GetHashCode()100%11100%
op_Equality(...)100%11100%
op_Inequality(...)100%11100%

File(s)

/home/runner/work/FixedMathSharp/FixedMathSharp/src/FixedMathSharp/Numerics/FixedCurveKey.cs

#LineLine coverage
 1using MemoryPack;
 2using System;
 3using System.Text.Json.Serialization;
 4
 5namespace FixedMathSharp;
 6
 7/// <summary>
 8/// Represents a keyframe in a <see cref="FixedCurve"/>, defining a value at a specific time.
 9/// </summary>
 10[Serializable]
 11[MemoryPackable]
 12public partial struct FixedCurveKey : IEquatable<FixedCurveKey>
 13{
 14    #region Fields
 15
 16    /// <summary>The time at which this keyframe occurs.</summary>
 17    [JsonInclude]
 18    [MemoryPackOrder(0)]
 19    public Fixed64 Time;
 20
 21    /// <summary>The value of the curve at this keyframe.</summary>
 22    [JsonInclude]
 23    [MemoryPackOrder(1)]
 24    public Fixed64 Value;
 25
 26    /// <summary>The incoming tangent for cubic interpolation.</summary>
 27    [JsonInclude]
 28    [MemoryPackOrder(2)]
 29    public Fixed64 InTangent;
 30
 31    /// <summary>The outgoing tangent for cubic interpolation.</summary>
 32    [JsonInclude]
 33    [MemoryPackOrder(3)]
 34    public Fixed64 OutTangent;
 35
 36    #endregion
 37
 38    #region Constructors
 39
 40    /// <summary>
 41    /// Creates a keyframe with a specified time and value.
 42    /// </summary>
 43    public FixedCurveKey(double time, double value)
 10244        : this(new Fixed64(time), new Fixed64(value)) { }
 45
 46    /// <summary>
 47    /// Creates a keyframe with optional tangents for cubic interpolation.
 48    /// </summary>
 49    public FixedCurveKey(double time, double value, double inTangent, double outTangent)
 950        : this(new Fixed64(time), new Fixed64(value), new Fixed64(inTangent), new Fixed64(outTangent)) { }
 51
 52    /// <summary>
 53    /// Creates a keyframe with a specified time and value.
 54    /// </summary>
 55    public FixedCurveKey(Fixed64 time, Fixed64 value)
 10856        : this(time, value, Fixed64.Zero, Fixed64.Zero) { }
 57
 58    /// <summary>
 59    /// Creates a keyframe with optional tangents for cubic interpolation.
 60    /// </summary>
 61    [JsonConstructor]
 62    public FixedCurveKey(Fixed64 time, Fixed64 value, Fixed64 inTangent, Fixed64 outTangent)
 4363    {
 4364        Time = time;
 4365        Value = value;
 4366        InTangent = inTangent;
 4367        OutTangent = outTangent;
 4368    }
 69
 70    #endregion
 71
 72    #region Equality
 73
 74    public bool Equals(FixedCurveKey other)
 1775    {
 1776        return Time == other.Time &&
 1777               Value == other.Value &&
 1778               InTangent == other.InTangent &&
 1779               OutTangent == other.OutTangent;
 1780    }
 81
 282    public override bool Equals(object? obj) => obj is FixedCurveKey other && Equals(other);
 83
 84    public override int GetHashCode()
 685    {
 686        return HashCode.Combine(Time, Value, InTangent, OutTangent);
 687    }
 88
 289    public static bool operator ==(FixedCurveKey left, FixedCurveKey right) => left.Equals(right);
 90
 191    public static bool operator !=(FixedCurveKey left, FixedCurveKey right) => !(left == right);
 92
 93    #endregion
 94}