< Summary

Information
Class: FixedMathSharp.FixedCurveKey
Assembly: FixedMathSharp
File(s): /home/runner/work/FixedMathSharp/FixedMathSharp/src/FixedMathSharp/Numerics/Curves/FixedCurveKey.cs
Line coverage
100%
Covered lines: 21
Uncovered lines: 0
Coverable lines: 21
Total lines: 103
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/Curves/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)
 11744        : 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)
 12356        : 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)
 4863    {
 4864        Time = time;
 4865        Value = value;
 4866        InTangent = inTangent;
 4867        OutTangent = outTangent;
 4868    }
 69
 70    #endregion
 71
 72    #region Equality
 73
 74    /// <inheritdoc/>
 75    public bool Equals(FixedCurveKey other)
 1776    {
 1777        return Time == other.Time &&
 1778               Value == other.Value &&
 1779               InTangent == other.InTangent &&
 1780               OutTangent == other.OutTangent;
 1781    }
 82
 83    /// <inheritdoc/>
 284    public override bool Equals(object? obj) => obj is FixedCurveKey other && Equals(other);
 85
 86    /// <inheritdoc/>
 87    public override int GetHashCode()
 688    {
 689        return HashCode.Combine(Time, Value, InTangent, OutTangent);
 690    }
 91
 92    /// <summary>
 93    /// Determines whether two FixedCurveKey instances are equal.
 94    /// </summary>
 295    public static bool operator ==(FixedCurveKey left, FixedCurveKey right) => left.Equals(right);
 96
 97    /// <summary>
 98    /// Determines whether two FixedCurveKey instances are not equal.
 99    /// </summary>
 1100    public static bool operator !=(FixedCurveKey left, FixedCurveKey right) => !(left == right);
 101
 102    #endregion
 103}